Frame Rates - Page 2
       by kirupa  |  3 November 2009

In the previous page, you learned about frame rates and how they work to make your animations look smooth or...not smooth. There is a hands-on side to all of this, and in this page, you will learn how this all works in Flash and also how to change the frame rate in Flash.

Flash and Frames and Rates
Flash, like many digital animation programs, abstracts away a lot of the details related to frames and frame rates. In fact, all you really ever have to worry about is your frame rate and how long your animation will be running for. Generating intermediate frames are taken care of by the tweening engine. The only times you have to worry about the intermediate frames is if you are actually drawing each frame by hand.

Let's look at how what you learned in the previous page applies in practice. For a 1 second animation, your timeline will look as follows:

The key things to notice are the values at the bottom right. The duration of the animation is 1 second, the frames per second is 24, and the playhead is currently on Frame 24. If I change the frame rate to 12, as you can guess, it now takes twice as long for the animation to finish:

The duration of my animation jumped from 1 second to 1.9 seconds. Despite all of this changing, notice that I never had to define additional frames. This should seem very casual because the equation for determining the frame rate is number of frames divided by the duration. You can mathematically manipulate these variables to solve for the missing value.

A 24 frame animation with a frame rate of 12 frames per second will take around 2 seconds to finish.

Using the UI to Change the Frame Rate
The most common way to change your frame rate is to use the Properties panel and change it globally for your entire application:

The default rate is 24 in more recent versions of Flash, and like I mentioned in the previous page, that is a good value to keep your frame rate at.

Programmatically Changing the Frame Rate
When you are working with more interactive types of animations, you may want to change your frame rate while your application is running. Fortunately, in ActionScript 3, you have easy access to the frame rate property.

The way you access the frame rate is through:

stage.frameRate

Because stage is global, you can call the frameRate property from pretty much anywhere in your application. You can easily set the frame rate value as well since this is a property that you can both read and write:

stage.frameRate = 25;

That's all there is to programmatically being able to set the frame rate. I never said it was complicated.

Conclusion
Well, this wraps up or overview of frames, rates, and everything in between in the world of Flash. The one thing I did not go into great detail is how my example on the first page was created, so I have provided the source for this below:

Download Source

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!


1 | 2




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.