I'm using URLStream to download 30-80mb files over HTTP. It downloads fine on Windows XP, but is extremely laggy in OSX. Anyone had similar issues? Here's some snippets of the code.
function startDownload():void
{
//opening file
var FileWriteStream:FileStream = new FileStream();
FileWriteStream.openAsync(DownloadingFile, FileMode.WRITE);
//adding listeners to stream
URLReadStream = new URLStream();
URLReadStream.addEventListener(ProgressEvent.PROGRESS, trackCurrentDownload);
URLReadStream.addEventListener(Event.COMPLETE, downloadComplete);
URLReadStream.addEventListener(IOErrorEvent.IO_ERROR, downloadError);
URLReadStream.load(DownloadURLRequest);
function trackCurrentDownload(event:ProgressEvent):void
{
//update progress bars
DownloadProgress.setProgress(event.bytesLoaded+resumeSize, event.bytesTotal);
if (URLReadStream.bytesAvailable > 2048 || event.bytesLoaded == event.bytesTotal)
{
//read stream & write bytes to file
var byteArray:ByteArray = new ByteArray();
URLReadStream.readBytes(byteArray, 0, URLReadStream.bytesAvailable);
FileWriteStream.writeBytes(byteArray, 0, byteArray.length);
byteArray = null;
}
}
}
I've tried different buffer sizes. I even commented out the PROGRESS event, and it still was laggy. Obviously I close everything & remove listeners in the downloadComplete function. Has anyone removed the PROGRESS event listener in the callback and added it back at the end of the callback? I'm really stumped, especially since it works fine on Windows. Thanks for any help or suggestions.