Flash actionscript 3.0: how to add click event dynamically in As3

how to add click event dynamically in As3

Posted by Sankar.G | Posted in | Posted on 2:43 PM

var i:Number;
for(i=0;i<=(buttonHolder.numChildren-1) ; i++)
{
buttonHolder.getChildAt(i).addEventListener(MouseEvent.CLICK, starter);
}

function starter(e:MouseEvent):void {
var ob=e.currentTarget;
trace(ob.name.substr(1));
}


select all buttons and create a movie clip and name it as buttonHolder and put this script it will work

Comments (0)