從外部加載可能很方便,但庫方法是可行的。 您需要要麼使用的LoaderInfo程序的applicationDomain的getDefinition()方法,或 flash.utils.getDefinitionByName();
應用領域例如:
for(var i:int = 0 ; i < imagesNum ; i++){
var ImageClass:Class = this.loaderInfo.applicationDomain.getDefinition('YourLinkageID'+i) as Class;
//I add 0,0 because since you have png, they will extend BitmapData which has width and height as compulsory
//constructor arguments. If the thing doesn't look right, use the actual dimensions instead of 0,0
var bitmap:Bitmap = new Bitmap(new ImageClass(0,0));
//display it or do whatever
}
getDefinitionByName例如:
import flash.utils.*;
for(var i:int = 0 ; i < imagesNum ; i++){
var ImageClass:Class = getDefinitionByName('YourLinkageID'+i) as Class;
var bitmap:Bitmap = new Bitmap(new ImageClass(0,0));
//display it or do whatever
}
HTH, 喬治