I'm trying to use an array to add a click listener to an existing Button. Black,Blue...etc are the button Names. the location of the nested button would be: this.mc1.mc2.contents.m3.black.addEventListener(MouseEvent.CLICK, doThisFunction);
var myArray:Array = new Array ("black","blue","green","orange");
for(var k:int =1; k<myArray.length; k++){
var kmc:MovieClip = (myArray[k] as MovieClip);
this.mc1.mc2.contents.m3.kmc.addEventListener(MouseEvent.CLICK, do开发者_StackOverflow社区ThisFunction);
}
Any help would be greatly appreciated!
First kmc
is a String:
var kmc:String = myArray[k];
Then the last line should be:
this.mc1.mc2.contents.m3[kmc].addEventListener(MouseEvent.CLICK, doThisFunction);
精彩评论