views:

34

answers:

1

Hello,

I would like to store a FileReference object somehow and load it when the SWF loads again.

I tried to use the SharedObject class but it does not seem to work. I suspect that what I want to do is not doable due to security issues (not using Adobe AIR), but I wanted to check.

Does anyone please know if there is anyway to store a FileReference object please and load it when the SWF is restarted?

Thank you very much,

Rudy

+2  A: 

I don't think you can store a FileReference into a SharedObject. Or at least, I don't think you could get the file data back, so in practice there's not much difference.

However, as of Flash Player 10, there's a load method in the FileReference object that lets you read the file (through the data property).

The data is accessed as a ByteArray, which can be serialized and stored into a SO for later retrieval. So you could ask the user to select a file, read its binary data and store it in a SO (there's a 100 Kb limit by default, so you would most likely have to ask the user for some extra space).

Next time your app is loaded, you should be able to get the file data from the SO (provided that the data was successfully saved and the SO has not been deleted).

Juan Pablo Califano
Thank you for your answer.The problem is that the user select a bunch of files that I store in a queue. Those files will later be uploaded. I don't really want to read them, just keep a FileReference so it could be uploaded later, when the user comes back.But I guess that is not doable.
Rudy
Yeah that would be a security hole if filereference could be serialized and deserialized. ByteArray is the right way to go ... (though I feel your pain -- loading 2 gb video files really isn't viable) ...
Daniel Hai