Creating a Loop

new ball review

Let's start by opening ball_addChild.fla

We may want to go back, so click File > Save As and name our new file: ball_for

Right now, our script adds a single child of the ball class, names it ball1, and positions at (100,150). What if we want to add a second child? Why not try it, with name ball2 and position (150,100):

var ball1:ball = new ball();
var ball2:ball = new ball();

That works:

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

... but it's going to get old real quick if we want to add even more balls to the stage. Imagine doing that twenty or thirty (or a hundred) times! Imagine changing your mind.... you'd lose your mind! There must be a better way.