0

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.

Gilad Novik
  • 4,546
  • 4
  • 41
  • 58

1 Answers1

0

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

Community
  • 1
  • 1
loxxy
  • 12,990
  • 2
  • 25
  • 56
  • Does this work for Air? I'm not sure, but maybe packaging an app for Air/iOS requires that everything be in the .fla – jhocking Jun 21 '11 at 21:34
  • The problem is that I still need to ship the resulting SWF to my clients. They are going to install it into their devices which do not have internet access (so it can't load anything outside the same FLA). – Gilad Novik Jun 21 '11 at 22:58
  • @jhoking : sorry, did not notice it being an AIR/iOS app before. @Gilad : Please notice edited answer. – loxxy Jun 22 '11 at 03:30
  • @loxxy : this is the first time I see this AS tag - it might be just what I was looking for! I need to embed about 2000 images (currently, resulting swf size is irrelevant), so basically I simply create 2000 entries with 2000 variables? Googling this tag resulted with a linkage ID option as well (for embedding SWF) - will it work for images as well (I prefer to have a linkage ID than another variable) Thanks!!! – Gilad Novik Jun 23 '11 at 04:09
  • @Gilad : Whatever you do, every embedded image will have a class associated with it, whether the number of images be 2 or 2000 (constant classes not variables). Also, you cannot put the two lines in a loop as Embed is a metadata directive, meaning it will be executed during compilation. – loxxy Jun 23 '11 at 05:16
  • @loxxy : I plan on modifying my script to generate the AS file with all the files embedded there. Thanks a lot, you solved my problem :) – Gilad Novik Jun 23 '11 at 16:45