第一种:用loader,具体细节会有多种方式。
1 public var loader:Loader; 2 public function ImageGroupDemo() 3 { 4 loader = new Loader(); 5 loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onCompleteHandler); 6 loader.load( new URLRequest("aaa.png") ); 7 } 8 9 public function onCompleteHandler(event:Event):void 10 { 11 var loadedImage:Bitmap = Bitmap(loader.content); 12 var bitMapData:BitmapData = new BitmapData(loadedImage.width,loadedImage.height,false,0xffffff); 13 bitMapData.draw(loadedImage,new Matrix()); 14 var image:Bitmap = new Bitmap(bitMapData); 15 addChild(image); 16 }
第二种方法,直接用Class,更为方便.
1 [Embed(source="aaa.png")] 2 public var BrownCollector:Class; 3 public function ImageGroupDemo() 4 { 5 addChild( new BrownCollector()); 6 }