PDA

View Full Version : No Event.COMPLETE for FileStream.writeUTFBytes()?


midimid
02-18-2009, 05:43 PM
Why is it that FileStream.openAsync() does not dispatch Event.COMPLETE when writing a file? If the file was really big (its not, but still...), how would I know when its done writing?

What if, for instance, I am writing a bunch of files in succession and I don't want to write one file until another one has already been written. Without an Event.COMPLETE I don't know when to close the stream.

fx.barrett
03-05-2009, 10:06 AM
I have the same problem but with FileStream.open(); and not only with the COMPLET event. It simply won't dispatch any kind of events. Anyone got any ideas on this ?

EDIT: I did run over this: http://bugs.adobe.com/jira/browse/SDK-12358 and from that, things aren't looking too good. If that is true, then we can't listen for an actual COMPLETE event although in theory we have one... Really bad, sad and weird at the same time...

midimid
03-05-2009, 04:48 PM
Any filemode other than write absolutely sends events for me.

For writing, in the end, I just made a function that writes data with openAsync taking a filename and file data as arguments. Its sort of a "call it and forget about it" function and I'm just making sure that anything I'm writing is small.

Fortunately, for me, that'll work fine for now.


private function saveFile(filename:String,data:*):void {
var dataFile:File = File.desktopDirectory.resolvePath(filename);
var filestream:FileStream = new FileStream();
filestream.openAsync(dataFile, FileMode.WRITE);
filestream.writeUTFBytes(data);
filestream.close();
}