views:

111

answers:

1

Hello

I am downloading and storing files locally in the app storage domain. For some reason one of the files gets locked by air. I found this by looking at process explorer.

If I clear the browser cache the file never gets locked, only if it attempts to download the file but it exists in browser cache does air lock the damn file.

Please can you help?

Neil

+1  A: 

Ok I have solved the problem. It has nothing to do with the browser caching the file, or rather not directly. I was re-using a FileStream object and downloading files asynchronously. So after each file has downloaded i can fileStream.close() and start downloading the next file.

Sometimes I would be re-using the fileStream before close had actually completed. The correct way is to add a listener to the fileStream object and then continue once it has closed.

eg:

fileStream.addEventListener(Event.CLOSE, checkCloseHandler);
fileStream.close();

private function checkCloseHandler(e:Event):void
{
    trace("FileCacheProxy.checkCloseHandler(): " + file.url);
    fileStream.removeEventListener(Event.CLOSE, checkCloseHandler);
    resumeQueue();
}
Neil