Search code examples
flashdirectoryfla

How to add a folder of pictures to a flash app?


I have a flash app (deployed as Air or regular app for iOS) which displays pictures.

It has to work offline, so I need to bundle my pictures with the flash app. I wrote a script to download all pics from my server to a specific folder before deploying the flash app. Currently, I remove all existing pictures from the FLA and add the new ones, but I was wondering whether there is a way to define a system folder for flash and it will take whatever exists there during the deployment process?

So basically all I'll have to do will be to run my script (to update the folder with the new pics) and recompile the FLA.


Solution

  • Well I don't know if flash offers any feature to ease your requirement directly. Also I didn't notice AIR, as there is no tag for the same. Anyways here is my 2 cents.

    • Use the document class (or the entry as3 file) to embed your resources.
    • Alter the class file with a script.

    Embedding is done by

    [Embed("ImageName.png")] const ImageName:Class;
    

    So every time your script adds an image into the folder, it can add the embed lines for the image into the Document class AS3 file. You may then access the resource in flash as usual,

    var obj:DisplayObject = new ImageName();
    

    EDIT:

    Every Image that is embedded should have a class associated with it. Or else, how else will you access the image after embedding. So whatever you do, every image needs a class. Dont worry about 2000 variables bloating memory or something. They will be managed just fine by flash during runtime.

    Also AS3 does not have access the to the file system at runtime so there could be no solution at that point.

    Here have a look at those people who had similar doubts & got similar responses

    http://flashpunk.net/forums/index.php?topic=2323.0

    Actionscript embed an array

    And here is a little of other metadata tags

    http://www.boostworthy.com/blog/?p=157