   [Flex]Loading an image programatically
  I've seen an exampl of how to create objects from images in Flex where the image is embedded as a special class. But I wish to load an image from a file - you can do it in MXML using an mx:Image tag but how would I do this programmatically. I can't find an example in the help, every class which looks useful seems to assume you already have your loaded image.Thanks.   
  you declare it like: [Embed(source="texture.jpg")]private var Texture:Class;and then instantiate it:var bmp:Bitmap=new Texture();;  Doesn't [Embed] cause the iamge to be compiled into the .SWF? When you do it through .mxml it actually loads the image from the source folder... I'll try it and see.But what if I have 10 file like 1.jpg, 2.jpg,... 10.jpg? Can I do this in a loop - is Embed a special command or just a normal langauge feature?I was expecting something like var x:Image = new Image("pictures/4.jpg") - does such a way exist?   ;  i think that is what you're looking for:http://livedocs.adobe.com/flex/2/langref/flash/display/Loader.html   ;  I haven't got it working yet, but apparently mx.controls.Image does what I need:private var image:Image = new Image();image.load("images/image001.png");;  So, I looked online at examples and they just don't work. But the embedded version does. Here is a simple test class:package src{import mx.controls.*;import mx.core.UIComponent;import flash.net.URLRequest;import flash.display.*;public class D000hg extends UIComponent{[Embed(source="../art/1.png")]private var IMG:Class;public function init():void{var sprite:DisplayObject = new IMG();sprite.x =35;sprite.y = 200;sprite.visible = true;addChild(sprite);var sprite2:SWFLoader = new SWFLoader();var url:String = "art/2.png";var urlReq:URLRequest = new URLRequest(url);sprite2.load(urlReq);sprite2.x =200;sprite2.y = 200;sprite2.visible = true;this.addChild(sprite2);var rect:Shape = new Shape();rect.graphics.beginFill(0xFFFFFF);rect.graphics.drawRect(300, 200, 100, 100);rect.graphics.endFill();addChild(rect);var ldr:Loader = new Loader();ldr.mask = rect;var url2:String = "art/3.png";var urlReq2:URLRequest = new URLRequest(url2);ldr.load(urlReq2);addChild(ldr);}}}The first one works; the other two don't. The difference in path (the ../) is not the cause, I've tried (it's due to the embedding).Having to embed all 40 images doesn't sound fun to me. What's wrong?   