views:

30

answers:

1

Is it possible, via Adobe Air, to save multiple types of data in a single file? For example, an application would allow the user to load in external images, position them on stage and label them. This data would be then be stored in a ByteArray (I guess) using BitmapData for the images and probably XML for the metadata.

I would then like to write this to a single file, with a bespoke file extension that could be associated with said Air app.

I've asked this on various forums and never received a single reply.

+1  A: 

You can add everything to a byte array and write it to file - but defining boundaries and extracting individual entities back from the file would take some effort. How about writing them to normal files, zipping them to a single file and deleting the originals? This way you can still have a single file and deal with the individual items more easily.

This article describes some ActionScript zip libraries. I've used nochump in the past and it was easy - this page has some sample code

If you want some individuality for your files, you can rename the zipped file to whatever extension you want - that's what Firefox extensions do, they have .xpi extension, but they're plain zip files renamed.

Amarghosh
Ok that does seem a much simpler way to do it, I shall look into it. In fact, effectively creating a .zip file makes things much easier for me in the long run. Thanks for your answer.
dr_tchock