PDA

View Full Version : Automate [Embed] pictures in a SWF ??


ccby
02-20-2008, 02:57 PM
Hi guys,

Possible or not possible in Action Script??

Background:
- a given folder
- many pictures in the folder (D1.jpg, D2.jpg, etc...screenshots genre)

Goal:
- automate the embedding of the pictures at compile time (for info, the future SWF will latter show synchronised screenshots with an audio recording)

Newbie problem:
- I know how to do it "by hand" (see below)
- I don't see how I can "automate" the embedding of the pictures, ie:

By hand (I search for an AS3 solution for now, UIcomponent gave me problems while trying to find a Flex solution):

~
"""
package
{
import flash.display.Sprite;

public class Main extends Sprite {

private var screenshots:Array = new Array(); // screenshots instances array

[Embed("../assets/screenshots/D1.jpg")] // how do I automate that?
private var Screen1:Class; // how do I automate that?
[Embed("../assets/screenshots/D2.jpg")] // how do I automate that?
private var Screen2:Class; // how do I automate that?

public function Main() {

screenshots.push(new Screen1()); // populate the screenshots array
screenshots.push(new Screen2());
addChild(screenshots[0]); // show the screenshots
addChild(screenshots[1]);
}
}

}
"""

If we know that in the given folder there is let say 30 screenshots, how do I automate the embedding of these pictures in the script above ? (or a Flex alternative?)

Or is it just impossible in Action Script 3 :(

Sounds like nobody was able to reply to this guy who had a similar question:
http://www.actionscript.org/forums/showpost.php3?p=637912&postcount=1

Hope it's possible in AS3 or Flex, I'm new to AS/Flex and I already had nightmare with the insane sandbox (I need to setup a proxy just to access a public XML feed...)

Please save me form Silverlight 2 Beta coming out very soon ....:eek:

Thanks

EndlessLine
02-20-2008, 05:08 PM
I know it is possible but you need to use PHP. I believe you use php to get the content of the folder and send them back to flash using flashVars. I'm not sure past that though. Definitely doable :)

springframework
02-20-2008, 05:23 PM
you can't do it.

if you want to embed an image it has to be done at compile time. therefor you have to code which images to embed.

i guess you could use a script language like perl/python to auto create this for you. Maybe flex has something like ANT that lets you run scripts in a certain order when compiling.

but still you have to code where you want to use the images, so you would have to at the very least make an array or class or something to use in a loop.


Jesse Couch Actionscript 3.0 (http://www.jessecouch.com)