Tying Actions to Events

Flash keeps track of every event that occurs while your animation plays, beginning with the instant Flash Player loads your animation and continuing through every frame Flash plays, every button your audience clicks, every key they press—basically, just about everything that happens in (or to) your animation.

You can tie an action to any event. The following sections show you how to tie actions to the most common events: when your animation loads, and when your audience clicks a button, mouses over a hotspot, or chooses an option from a list.

Triggering an Event When Your Audience Clicks a Button

In Chapter 7, you saw how to create groovy-looking button symbols (and where to find the button symbols that come with Flash), as well as how to change the appearance of a button when someone mouses over it.

This section shows you how to tie a button to an action so that when your audience clicks the button, Flash does something.

Top: Working as designed: Clicking the button without having typed in any text shows this result.Bottom: Surrounding input values with colons, as shown here, is an old programmer's trick. As far as programming languages go, a space is a value; using colons reminds you of this counterintuitive fact.

Figure 11-7. Top: Working as designed: Clicking the button without having typed in any text shows this result. Bottom: Surrounding input values with colons, as shown here, is an old programmer's trick. As far as programming languages go, a space is a value; using colons reminds you of this counterintuitive fact.

The example below uses a quick and easy behavior to tell Flash to load an additional animation when your audience clicks a button. But ...

Get Flash CS3: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.