@Embed is a compile-time thing, so it won't help you at run-time.
You'll have to type-out your @Embeds for every thing you want embedded, then if you name the variables in some order you can compute the name at run-time
Public var image1:Class;
Public var image2:Class;
Flex SDK Developer
Adobe Systems Inc.
Yes, I had it like that, but that requires me to know in advance in my code how many image classes to create.
I want to assign them based on the number of XML nodes in the for each(var step:XML in dataXML) loop.
At least in theory you could compile the images into a resource SWF, and then at run-time load the resource SWF and access the class names at that time. You still need to know something in advance, but it provides a bit more flexibility.
I think to do this you would create an ActionScript class with the embedded images as Alex described, and then compile the class with mxmlc or perhaps compc.
Hi there, when you use @Embed that means the image gets compile inside the swf at compile-time, you could just load images at runtime, removing the @Embed(source=).
Yes, I know, but that means they have to be on the server. I will do that if all else fails, but I hoped for a solution wherein I only have to provide the SWF of my application and the XML file, no graphics or additional swfs.
Base on what u need, u will have to embed all the images in your source, though you can assign them in during run time.
[Embed(source='xxx.png')] public var img1:Class;
new myImg1:Image = new img1() as Image;
if you get a broken image by embeding, check if the image path is wrong
my conundrum is I don't know how many images I will need; that's why I am using the loop through the xml file. There could be 5 or 20.
So is there a way to generate the code you indicate using the same or similar loop?
no way if that''s a run time xml file.
embed means compile the image into swf file