Task: A Rotating Movie Clip

I l @ ve RuBoard

You can easily write a movie clip handler that rotates the movie clip at a constant rate. All you need to do is increase the _rotation property.

  1. Start with an empty Flash movie.

  2. Place a simple movie clip in the middle of the screen. Don't use a simple circle, though, because it will not appear to change while it rotates.

  3. Attach the following script to the movie clip:

     onClipEvent(enterFrame) {     this._rotation += 1; } 

    When you run the movie, the movie clip rotates 1 degree per frame. This means that it will take 360 frames to rotate completely around. At 15 frames per second, that's 24 seconds for a complete turn . That is, of course, if your computer can handle the full rate of animation. If you keep the movie clip and any other elements in the movie simple, this should not be a problem.

  4. To make the movie clip spin twice as fast, change the 1 to a 2. Try other values as well.

  5. To make the movie clip rotate in the opposite direction, change the number to a negative value, such as -1. Alternatively, use -= instead of += . Check out the example movie 07rotation.fla to see an example.

I l @ ve RuBoard

Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net