O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Choosing Between Timer and Event.ENTER_FRAME

As we've just seen, the Timer class and the Event.ENTER_FRAME event can both be used to produce animation. So which one is right for your family? Here are the major factors to consider:

Frame rate is subject to change

When a .swf file is loaded by another application, the frame rate of that application might be vastly different than the .swf file's designated frame rate, potentially causing the .swf's animations to play too quickly or too slowly. The loaded .swf file can, of course, set the frame rate, but that change in frame rate might cause undesirable playback behavior in the parent application. The Timer class offers some frame-rate independence (subject to the limitations discussed in the earlier section "Frame Rate's Effect on Timer").

Using many Timer objects requires more memory

In decentralized animation management architectures, using a separate Timer to control the animation of each object requires more memory than would be required by the analogous Event.ENTER_FRAME implementation.

Using many Timer objects can cause excessive screen update requests

In decentralized animation management architectures, using a separate Timer in conjunction with updateAfterEvent( ) to control the animation of each object leads to multiple independent requests for screen updates, possibly leading to performance problems.

Based on those factors, here are the recommended best practices:

  • In applications that must synchronize the display of programmatic ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required