O'Reilly logo

Learning ActionScript 3.0 by Zevan Rosser, Rich Shupe

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

Frame and Timer Events

We've been using mouse and keyboard events because you're almost certainly familiar with them to some degree, and they are ideally suited to this tutorial context. However, there are many, many events in the ActionScript language. While it's not possible to cover every one, we would like to round out the chapter with two other significant other event types: frame and timer.

Frame Events

Frame events are not triggered by user input, the way mouse and keyboard events are. Instead, they occur naturally as the Flash file plays. Each time the playhead enters a frame, a frame script is executed. This means that frame scripts execute only once for the life of the frame, making them an excellent location for seldom-executed tasks, such as initializations. In other words, for a frame script to execute more than once, the playhead must leave the frame and return—either because of an ActionScript navigation instruction, or a playback loop that returns the playhead to frame 1 when it reaches the end of the timeline.

However, using an event listener, you can listen for a recurring enter frame event that some display objects have, including the main timeline and the movie clips. An enter frame event is fired at the same pace as the document frame rate. For example, the default frame rate is 12 frames per second, so the default enter frame frequency is 12 times per second. Using the enter frame event allows your file to update frequently—a particularly handy thing for visual ...

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