I have 24 elements set and pushed to an array with this code:
gridArray = new Array();
for (var x:uint=0 ; x <6 ; x++ ){
for (var y:uint=0 ; y<4 ; y++){
var c:Tile = new Tile();
c.x = x*77 + 45;
c.y = y*77 + 5;
addChild(c);
gridArray.push(c);
}//end of for
}//end of for
then i assign listeners :
public function new_set(){
for (var i:uint=0 ; i<24 ; i++){
gridArray*.tile_anim.gotoAndStop(anim);
gridArray*.addEventListener(MouseEvent.CLICK, wrong_click);
}
//choose a random tile
var r:uint = Math.floor(Math.random()*24);
gridArray[r].tile_anim.gotoAndStop(anim+1);
//assign a different event listener
gridArray[r].removeEventListener(MouseEvent.CLICK, wrong_click);
gridArray[r].addEventListener(MouseEvent.CLICK, good_click);
}//end of new_set()
I need to know what to put in the function
function wrong_click(event:MouseEvent):void{
trace("Are You blind you *******?!?");
}
to make the CLICKED element gotoAndStop(2)?!?
I tried some weird stuff like this.gotoAndStop(2), or gridArray[this].gotoAndStop(2), but thise were only my guesses. Of course they didn’t work. How can i do that?