Working with Arrays

Review

Programmers use arrays to index multiple copies of the same object. Arrays come in handy when working with databases. If you think about it, we are building quite a little database with our balls, each of which has it's own properties with values that need to be stored somewhere and accessed somehow.

It's totally understandable if you're still slightly confused. Don't be discouraged! We'll continue working with arrays, and you'll get it soon enough.

What We Did

  1. Created a file called ball_array
  2. Created a new array called balls
  3. Added copies of ball to the stage and updated the balls array to track each ball
  4. Created an init function to group the statements we want to run at the start of the program
  5. Used a for loop to set the Y position of all the balls outside the init function

Important ActionScript

var balls:Array
balls = new Array();
balls.push(myBall);