A Rotating Movie Clip

written by: Paulo Caldeira; article published: year 2007, month 07;


In: Root » Computers and technology » Flash » A Rotating Movie Clip

Dutch French Spanish Portuguese Italian German Japanese Chinese Korean Russian Arabic Bookmark and Share this Article

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:

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.

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 +=.

Disclaimer

1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here.

link to this article