我正在尝试使用数组向现有Button添加点击侦听器。 黑色,蓝色......等按钮名称。 嵌套按钮的位置是: 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, doThisFunction);
}
非常感谢任何帮助!
答案 0 :(得分:0)
第一个kmc
是一个字符串:
var kmc:String = myArray[k];
然后最后一行应该是:
this.mc1.mc2.contents.m3[kmc].addEventListener(MouseEvent.CLICK, doThisFunction);