views:

89

answers:

1

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!

A: 

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);
David Wolever
That certainly helps a lot! It's creating the first 2 listeners (I changed the myArray[k] to myArray[k-1]) and not the last 2. Did I miss something on the 'for' statement?
gjthoman
Never mind, I had a copy of the MC over the clip I was trying to click... Thanks for your help!
gjthoman
No problem :) Thanks for the accept.
David Wolever