AS3 How-Tos and Tips > Testing the Frame Rate - an Example

In this How-To, we discuss the issue of the frame rate, FPS, of a Flash movie. We give a simple class, BasicInfo, that displays memory consumption and the frame rate as a movie runs. We also present a simple test example displayed below. Experiments with this example show that the frame rate differs hugely from browser to browser. What you get in the Test Player as you test your fla file in the Flash CS4 IDE is not what you will see in the browsers on the same system.


  • Download the source files for our example:

What We Observed

In the example above, the frame rate, FPS, of the movie can be adjusted programmatically at runtime to any value between 6 FPS to 300 FPS. We imposed those limits arbitrarily as the Flash Player will accept any value for FPS between 0.01 and 1000. You can download the source code from the link above,, and change those limits.

Our experiments showed that on a Windows XP SP3 machine (Pentium Extreme, very fast), in the Test Player (when the 'fla' file was tested within the Flash CS4 IDE) the movie easily reached 300 FPS. Similarly, in the stand alone Flash Player. On the same system, the movie would not go over 65 FPS in the Internet Explorer 8 (with the latest release version of the FP). In Firefox, however, it did go to 300 FPS exactly as in the Test Player.

On a Mac OS X 10.4.11, the movie barely reached 60 FPS on Safari, Firefox, in the Test Player within Flash CS4, and in the stand alone Flash Player.

The good news is that in every one of the above configurations, the example ran fine at 24 FPS.

We did not observe any significant differences in memory management.

The BasicInfo AS3 Class

This class is similar in nature to the very popular, versatile, industrial strength class, 'Stats' by: Mr. doob. You can find the latest version of the 'Stats' class at Mr. doob Wiki.

Our class is designed to be much simpler, shorter and more basic. It displays only the current FPS and memory use. Also, we calculate the FPS a bit differently.

What is Frame Rate and How to Change It Programmatically

The frame rate of a Flash movie, in fps - frames per second - is the frequency with which the screen will undergo a scheduled update as your movie plays. The changes of the screen performed during the update may reflect the playhead moving to the next frame of your movie, but equally often the playhead is not moving and the changes of the screen result from the user's interaction, from firing of a Timer event, or from executing an ENTER_FRAME event handler. Thus, the frame rate is not directly ralated to the frames and keyframes of your movie's Timeline in the Flash authoring environment. For example, if you animate an object programmatically, your fla file may have only one frame on the Timeline with AS3 code attached to it. The code might be written to create motion of your object using a Timer or the ENTER_FRAME event. (ENTER_FRAME is fired precisely at the sheduled screen update mandated by frame rate.) The MainTimeline of the example on this page has only one frame; the ball reponds to ENTER_FRAME handler. A better name for the frame rate would be 'screen update rate' or 'scheduled display refresh rate'.

Having said that, we need to make an important point that this How-To is designed to illustrate: the actual current frame rate of your movie may differ from the rate set in the Flash authoring environment or via AS3. The Flash Player may not be able to keep up with the scheduled updates of the screen at the set frame rate due to a heavy rendering load or lots of calculations. The performance depends hugely on the browser, on the platform, and on the user's system. Thus, the actual current frame rate may be changing as your movie runs and may differ from the one set by you.

To set a new frame rate programmatically at runtime use the frameRate property of the 'stage' object. For example:



The class BasicInfo displays memory consumption. We didn't notice significant differences in the memory management between the Test Player and the browsers' plugins. You can check the memory consumption in the Test Player (as well as the FPS) with a few lines of code. For that, see another of our How-Tos: Simple Code to Test Memory Consumption and Frame Rate of a Flash Movie.

Back to AS3 How To and Tips              Back to Flash and Math Home

We welcome your comments, suggestions, and contributions. Click the Contact Us link below and email one of us.

Adobe®, Flash®, ActionScript®, Flex® are registered trademarks of Adobe Systems Incorporated.