actionscript 3 - AS3 using array to add EventListener to existing Button -


I'm trying to use an array to add an existing listener to a click listener. Black, Blue ... etc button names are the location of nested buttons: 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 & lt; myArray.length; k ++) {var kmc: Movie clip = (myArray [k] as a movie clip; This.mc1.mc2.contents.m3.kmc.addEventListener (MouseEvent.CLICK, doThisFunction); }

Any help would be greatly appreciated!

first kmc is a string:

  var kmc: string = marie [k];  

Then the last row should be:

  this.mc1.mc2.contents.m3 [kikak] .addEventListener (MouseEvent.CLICK, doThisFunction);  

Comments