Rotation Movement

Let's get the lines to continually rotate around the center point. Start the onEnterFrame function:

  1. Select the last brace of the init function - you don't want the onEnterFrame function inside a function
  2. Click Statemnts > Function > function
  3. Type onEnterFrame (Remember: this function is cAse sEnsitive so capitalize exactly as I have)

onEnterFrame

Create a for loop just like you did with the init function. You can even use the same variable name:

function onEnterFrame(){
     for (n=0;n<numLines;n++){
     }
}

Repeat the var action again and practice setting the data type... just like before:

function onEnterFrame(){
     for (n=0;n<numLines;n++){
          var line:MovieClip = this["main"+n];
     }
}

Now let's rotate each line one degree. You can do this with set variable: line._rotation = line._rotation+1; but let's think ahead and make this easier to customize later by using a variable called rotaSpeed (I made that name up) instead of the number 1.

  1. Use var to set rotaSpeed = 1 and set the data Type to Number
  2. Use set variable to make line._rotation = line._rotation+rotaSpeed;

Great! You can easily alter the number of objects and the rotation speed at the start of the script. The example below has 22 lines: