AS3 Event.COMPLETE传递参数

问题描述 投票:0回答:1

我正在尝试在Event.Complete上传递参数,因此一旦它们加载图像,我就可以相应地处理它们的位置,存储它们,等等。请参见下面的代码和输出:

var pic:Array = ["https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png","https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png","https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png","https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"];

for (var ii: uint = 0; ii < pic.length; ii++) {

var imageURLRequest:URLRequest = new URLRequest(pic[ii]); 
var myImageLoader:Loader = new Loader(); 
myImageLoader.load(imageURLRequest); 
trace ("the ii: " + ii);

myImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(evt:Event)
{
   doIt(evt, ii)
} , false, 0, true);

function doIt(evt:Event, msg:int) {
    //var myBitmapData:BitmapData = new BitmapData(myImageLoader.width, myImageLoader.height); 
    //myBitmapData.draw(myImageLoader); 
    //var myBitmap:Bitmap = new Bitmap; 
    //myBitmap.bitmapData = myBitmapData; 
    trace ("message : " + msg);
}
}

/////Output
the ii: 0
the ii: 1
the ii: 2
the ii: 3

message : 4
message : 4
message : 4
message : 4

///Expected Output

/////Output
the ii: 0
the ii: 1
the ii: 2
the ii: 3

message : 0 
message : 1
message : 2
message : 3

感谢您的帮助Speego

actionscript-3 flash
1个回答
0
投票

已解决的谢谢👍👍能够弄清楚它的包装。

© www.soinside.com 2019 - 2024. All rights reserved.