
Best practices for using behaviors
99
Many developers do not place ActionScript on symbol instances, and instead place their code
on the Timeline (timeline code) or in classes. Because Behaviors add code to many locations
in a FLA file, it means that your ActionScript is not centralized and can be difficult to locate.
When code is not centralized, it is difficult to figure out interactions between the snippets of
code, and it is impossible to write code in an elegant way. It can potentially lead to problems
debugging code or editing files. Many developers also avoid placing code on different frames
on the Timeline or avoid placing timeline code inside multiple movie clips where it is hidden.
By placing all your code, including functions that must be defined before they are used, in a
SWF file, you can avoid such problems.
Flash has features that make it easy to work with behaviors in a document and with
decentralized ActionScript. If you use behaviors, try the following features when working on
your project:
Script navigator
Makes your timeline code or code on individual objects easy to find and
edit in the Actions panel.
Find and replace
Lets you search for strings and replace them in a FLA document.
Script pinning
Lets you pin multiple scripts from various objects and work with them
simultaneously in the Actions panel. This works best with the Script navigator.
Movie Explorer
Lets you view and organize the contents of a FLA file and select elements
(including scripts) for further modification.
Using behaviors
Knowing when to use behaviors is the most important guideline. Carefully consider your
project and whether behaviors are the best solution for you, which can be determined by
answering the questions that follow. Consider different ways of structuring your projects, as
well as the different options and features available in Flash.
If you have a FLA file with symbols, you can select one of the instances on the Stage, and then
use the Add menu on the Behaviors panel to add a behavior to that instance. The behavior
you select automatically adds code that attaches to the instance, using code such as the
on()
handler. You can also select a frame on the Timeline, or a slide or form in a screen-based FLA
file, and add different behaviors to a frame or screen using the Behaviors panel.
Summary of Contents for FLASH 8-FLASH
Page 1: ...Using Flash ...
Page 12: ...12 Contents ...
Page 110: ...110 Using Symbols Instances and Library Assets ...
Page 128: ...128 Working with Color Strokes and Fills ...
Page 156: ...156 Drawing ...
Page 190: ...190 Working with Text ...
Page 224: ...224 Working with Graphic Objects ...
Page 270: ...270 Creating Motion ...
Page 310: ...310 Working with Video ...
Page 362: ...362 Working with Screens Flash Professional Only ...
Page 386: ...386 Creating Multilanguage Text ...
Page 454: ...454 Data Integration Flash Professional Only ...
Page 500: ...500 Publishing ...
Page 534: ...534 Creating Accessible Content ...