AS3 : Setting the instance name of a loaded swf
I am running a for loop that loads swfs onto the stage. _componentData is an XMLList.
private function loadDevices():void
{
for each (var d:XML in _componentData.device)
{
var iname:String = d. @ iname;
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest(d. @ path);
mLoader.contentLoaderInfo.addEventListener(Even开发者_高级运维t.COMPLETE, onDeviceLoadComplete);
mLoader.load(mRequest);
}
}
Inside onDeviceLoadComplete i want to be able to set the instance name of the loaded swf. Can i send extra parameters to the event handler function? Or is there a better approach?
Pretty sure you can't change an instance name on a dynamically-generated object. In any case, it would probably be easier to push them into an array for reference. You could use associative keys in the array and reference them as such:
var myArray:Object = new Object();
myArray.apple = "red";
for (var item in myArray) {
trace(item); // apple
trace(myArray[item]); // red
}
I found a nice link that pointed me in the right direction since i cannot set the instance name.
What i am doing is setting the name prop of the loader to iname and then using e.target.loader.name instead of the instance name. From there i am able to move forward in my development. Thanks!
精彩评论