onEnterFrame

Now we get to make things move using the onEnterFrame function. Remember this is a powerful built-in function that tells Flash to run the actions between the braces constantly, just like a looping timeline.

  1. Select the closing brace for the init function - our new function must go outside the braces
  2. Click Statements > User-Defined Functions > function
  3. Type onEnterFrame in the Name box (it's case sensitive, so be careful)

We are going to repeat some of the same actions you already have going on in the init function, including the for loop. Rather than re-type everything, it will be quicker to just duplicate the actions and modify what we need to modify.

Right-Click the start of the for statement and Copy. If you have Script Assist on, the entire for statement (including everything between the braces) will be copied:

Now Paste between the braces that define the onEnterFrame function. To get between the braces, Right-Click on the opening brace:

OK, if you test your work right now, it'll be kinda funny.