When I run this code, the file is written successfully, but none of the events fire (or is the process happneing so quickly to the point that they do not appear). Any help would be appreciated.
import flash.net.FileReference;
import flash.filesystem.*;
var myFile:File = File.documentsDirectory.resolvePath("AIR Test/test.txt");
var myFileStream:FileStream = new FileStream();
myFileStream.addEventListener(Event.COMPLETE, completeHandler);
myFileStream.addEventListener(ProgressEvent.PROGRESS, progressHandler);
myFileStream.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
myFileStream.openAsync(myFile, FileMode.WRITE);
myFileStream.writeUTFBytes("Hello world");
function completeHandler(event:Event):void {
// ...
trace("Complete")
}
function progressHandler(event:ProgressEvent):void {
// ...
trace("Progress")
}
function errorHandler(event:IOErrorEvent):void {
// ...
trace("Error")
}