• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Hour 7. Moving and Changing Movie Clips > Task: A Rotating Movie Clip

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.

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.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint