function moveBall(evt:Event):void{
// when use ball.x one of the ball will move
ball.x += 2;
// However ball0.x, ball1.x … ball5.x not working with errors
}
I tried to use the function moveBall to control their movement. However it seems that their instance names are not ball0, ball1, ball2…ball5. Could you please provide some guidlines for me?
You don’t use the instance name reference explicitly in an event listener.
Hmm, on second reading… you’ll need to do things quite differently.
ball.x will refer to the most recently created ball, as above you are assigning a reference to a MC to “ball”. You can either create six separate ball references, or use getChildByName to get a reference to each ball, but that can be quite slow.
ball1 through ball6 exist in the display list - this isn’t like AS2 where MCs and the like all existed together with variables.