Hi every body, I’m quite new in action script 3. I have a problem with for loop naming in AS3.
So what i want is action script is looping and add several movie clip to the stage (same movieclip). Then each movieClip added an event listener with several different function.
here is the sample script i can do right now.(which’s not working)
var myX:Number = -200
for(var i:Number=0 ; i<5 ; i++){
var myMc_mc:MovieClip = new mc;
myX +=200
myMc_mc.x= myX
myMc_mc.name= “mc”+i;
addChild(myMc_mc)
}
myMc_mc.mc1.addEventListener(MouseEvent.CLICK,myFunction)
myMc_mc.mc2.addEventListener(MouseEvent.CLICK,myFunction2)
function myFunction(e:MouseEvent):void{
trace(“clicked”)
}
function myFunction2(e:MouseEvent):void{
trace(“clicked2”)
}