Introducing Behaviors


Behaviors are a collection of some of the more commonly used applications of ActionScript organized in a panel. The panel's name: the Behaviors panel. Strange, but true. In this aptly named panel, you will find behaviors to open web pages, control movie clip Timelines, load JPEG images or SWF files into movie clip instances, and behaviors to control sounds. These behaviors are added directly from the panel, and the panel has a feature that lets you change what event causes the behavior to trigger in all but one circumstance. When you become an ActionScript ace, you can write your own behaviors and add them to the panel, but until then you can download and install additional behaviors that are written by third-party companies and members of the Flash community. One of the best sources for these third-party behaviors is Macromedia Exchange (www.macromedia.com/go/exchange).

There are two places in which you can add behaviors: keyframes in a Timeline or directly to movie clip, button, or component instances (ever after referred to collectively as objects). When you select an item to add a behavior to, be it an object or a keyframe in a Timeline, the Behaviors panel itself will show what has actually been selected, so you can avoid adding a behavior to the wrong item by mistake. The behaviors you can add will depend on what's been selected.

Tip

Many of the behaviors in the Behaviors panel were written with the idea that the developer or designer would add them directly to object instances. Although this is okay when you're starting out, it's generally considered a better practice to add all your ActionScript to a keyframe in the Timeline because it's easier to find and fix when things start to go wrong. More on this practice in Lesson 9.


The next couple of exercises cover how to use behaviors to add basic interactivity to your application. First, you'll add a behavior that loads a JPEG image off your hard drive and into your Flash application on the fly. Then, you'll add some behaviors that control movie clip Timelines.




Macromedia Flash 8. Training from the Source
Macromedia Flash 8: Training from the Source
ISBN: 0321336291
EAN: 2147483647
Year: 2004
Pages: 230
Authors: James English

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net