使用 FileStream 載入文字檔案(僅限 AIR 執行時)
有關如何同步讀取 UTF 文字檔案的簡單示例。
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
//First, get a reference to the file you want to load
var myFile:File = File.documentsDirectory.resolvePath("lifestory.txt");
//Create a FileStream object
fileStream = new FileStream();
//open the file
fileStream.open(myFile, FileMode.READ);
//read the data and assign it to a local variable
var fileText:String = fileStream.readUTF();
//close the current filestream
fileStream.close();