我已经在库中创建了一个包含my-Classes名称的数组。
var myArr:Array = new Array("myPic1","myPic2","myPic3");
通常如果我想创建我班级的对象,我会
var libraryImage:Bitmap;
libraryImage = new Bitmap(new myPic1(0,0));
但是如何迭代数组并动态创建我的图像呢?
for(var i:uint = 0; i<myArr.length; i++){
var libraryImage:Bitmap;
libraryImage = new Bitmap(new myArr[i](0,0));
}
不起作用
答案 0 :(得分:0)
试试这个:
var myArr:Array = new Array(new myPic1(0,0), new myPic2(0,0), new myPic3(0,0));
for(var i:uint = 0; i<myArr.length; i++){
var libraryImage:Bitmap;
libraryImage = new Bitmap(myArr[i]);
}
答案 1 :(得分:0)
你可以做这样的事情
for(var i:uint = 0; i<myArr.length; i++){
var myClass:Class = getDefinitionByName(myArr[i]) as Class;
var libraryImage:Bitmap;
libraryImage = new Bitmap(new myClass(0,0));
}