先用Loader()将图片加载进来,不直接addChild()进到stage,将其转换Bitmap格式再载入
用BitmapData .draw(loader);
再对BitmapData对象用Bitmap类载入即可
import flash.display.Bitmap;
import flash.display.BitmapData;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest("banner.jpg"));
function completeHandler(event:Event){
var _content:DisplayObject = event.target.content;
var bmpData:BitmapData = new BitmapData(400,200);
bmpData.draw(loader);
var bmp:Bitmap = new Bitmap(bmpData);
this.addChild(bmp);
bmp.x = 200;
bmp.y = 120;
}