BitmapData
您可以在加载程序初始化时将加载程序绘制到对象上,然后Bitmap
在加载程序完成时简单地使用它来创建所需数量的对象。
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.events.Event;
var loaderBitmapData:BitmapData;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, loaderInitEventHandler);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteEventHandler);
loader.load(new URLRequest("eXO-01.png"));
function loaderInitEventHandler(event:Event):void
{
loader.contentLoaderInfo.removeEventListener(Event.INIT, loaderInitEventHandler);
loaderBitmapData = new BitmapData(event.target.width, event.target.height);
loaderBitmapData.draw(event.target.loader as Loader);
}
function loaderCompleteEventHandler(event:Event):void
{
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loaderCompleteEventHandler);
createBitmaps();
}
function createBitmaps():void
{
var image1:Bitmap = new Bitmap(loaderBitmapData);
image1.scaleX = image1.scaleY = 0.2;
var image2:Bitmap = new Bitmap(loaderBitmapData);
image2.scaleX = image2.scaleY = 0.4;
image2.x = image2.y = 100;
addChild(image1);
addChild(image2);
}