使用 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();