Question

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, doThisFunction);
    }

Any help would be greatly appreciated!

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top