O'Reilly logo

Flash CS5.5: The Missing Manual by Chris Grover

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

Chapter 13. Controlling Actions with Events

In the previous chapter, you learned how to use ActionScript to move, transform, and change parts of your animation. But when something happens is just as important as the action itself. For example, you may want a movie object to start playing as soon as the web page opens, or you may want to let your audience decide when to watch it. You use events to control the actions in your animation. It’s as if your ActionScript program tells Flash: “When this (event) happens, do this (action).” The classic example is a button on the stage. The action statement says something like: “When this button gets clicked, go to Frame 25 of the movie clip, and then start playing.” You provide the programming that puts the people who view your Flash creations in the driver’s seat. Using events and event handlers, you can send your programs off into the world on their own, confident that they’ll behave.

This chapter explains how to use ActionScript to detect events when they happen and how to get your animations to perform specific actions as a result. Unlike previous versions, ActionScript 3.0 has one single way of handling all kinds of events. So, once you learn the basics, you’re all set to handle any event.

How Events Work

There are many different types of events. Some events—like a mouse click—are triggered by the people viewing your animation. Other events are simply occurrences in a Flash animation—like a movie clip reaching the last frame. The button ...

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