AS3 Working With Arbitrarily Large Files

Posted by Kekoa on Stack Overflow See other posts from Stack Overflow or by Kekoa
Published on 2010-02-23T21:40:37Z Indexed on 2010/03/19 15:51 UTC
Read the original article Hit count: 506

Filed under:
|
|
|
|

I am trying to read a very large file in AS3 and am having problems with the runtime just crashing on me. I'm currently using a FileStream to open the file asynchronously. This does not work(crashes without an Exception) for files bigger than about 300MB.

_fileStream = new FileStream();
_fileStream.addEventListener(IOErrorEvent.IO_ERROR, loadError);
_fileStream.addEventListener(Event.COMPLETE, loadComplete);
_fileStream.openAsync(myFile, FileMode.READ);

In looking at the documentation, it sounds like the FileStream class still tries to read in the entire file to memory(which is bad for large files).

Is there a more suitable class to use for reading large files? I really would like something like a buffered FileStream class that only loads the bytes from the files that are going to be read next.

I'm expecting that I may need to write a class that does this for me, but then I would need to read only a piece of a file at a time. I'm assuming that I can do this by setting the position and readAhead properties of the FileStream to read a chunk out of a file at a time. I would love to save some time if there is a class like this that already exists.

Is there a good way to process large files in AS3, without loading entire contents into memory?

© Stack Overflow or respective owner

Related posts about as3

Related posts about actionscript-3