Task: A Rotating Movie Clip
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.
-
Start with an empty Flash movie.
-
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.
-
Attach the following script to the movie clip:
-
To make the movie clip spin twice as fast, change the 1 to a 2. Try other values as well.
-
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.
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.