O'Reilly logo

Flash 8: The Missing Manual by E. A. Vander Veer

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

Adding a Prebuilt Behavior

Adding a behavior in Flash is similar to adding an action: In both cases, you add ActionScript code to the Actions panel. But in the case of adding an action, you have to type the ActionScript code; when you add a behavior to your animation, Flash types the code for you.

Top: Smiley as he first appears, before you move your mouse over his left squinched-up eye.Bottom: Because Smiley's left eye is a button symbol, mousing over it tells Flash to turn your arrow cursor into a pointing finger. Clicking Smiley's left eye lets you drag Smiley around the test window. He stays where you drop him (until you click his left eye and drag him again).

Figure 9-7. Top: Smiley as he first appears, before you move your mouse over his left squinched-up eye. Bottom: Because Smiley's left eye is a button symbol, mousing over it tells Flash to turn your arrow cursor into a pointing finger. Clicking Smiley's left eye lets you drag Smiley around the test window. He stays where you drop him (until you click his left eye and drag him again).

Adding a behavior actually requires a few more steps and clicks than it would take an experienced scripter to type a quick ActionScript from scratch. But behaviors let you reap the benefits of ActionScript without learning anything about scripting.

Flash includes only a couple dozen behaviors, one of which does the same thing as the ActionScript described in the previous section. Here's how to make a button object draggable using a behavior:

  1. Open the document hotspot_drag_begin.fla.

    You can download this file from the book's "Missing CD" page. For a working copy, download drag_behavior.fla.

  2. On the Stage, click Smiley's left eye.

    Flash highlights the instance of the leftEye button symbol and displays instance-related ...

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