I’m trying to create dynamic balls by using a for loop. For some reason I get two objects (trace show 2 balls and their DIFFERENT properties), but on the stage I can see just a last one created.
This is my code:
var randomBall_mc:ball=new ball(); for (i=1; i<3; i++) { addChild(randomBall_mc); randomBall_mc.name='randomBall'+i; randomBall_mc.x=150*i; randomBall_mc.y=175; randomBall_mc.height=20*i; randomBall_mc.width=20*i; trace('randomBall'+i); trace(randomBall_mc.x); trace(randomBall_mc.height); }
What is wrong in my code?
var randomBall_mc:ball=new ball(); should be inside the for loop in order to create more than ONE ‘ball’