User Guide
106 Chapter 3: Using Best Practices
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.
You need to decide when you need to use behaviors instead of writing ActionScript. First, answer
the questions in the introductory section “Behaviors conventions” on page 105. Examine how
and where you want to use behaviors and ActionScript in your FLA file. Then, consider the
following questions:
• Do you have to modify the behavior code? If so, by how much?
• Do you have to interact with the behavior code with other ActionScript?
• How many behaviors do you have to use, and where do you plan to put them in the FLA file?
Your answers to these questions determine whether you should use behaviors. If you want to
modify the behavior code to any extent, do not use behaviors. Behaviors usually cannot be edited
using the Behaviors panel if you make modifications to the ActionScript. And if you plan to
significantly edit the behaviors in the Actions panel, it is usually easier to write all of the
ActionScript yourself in a centralized location. Debugging and modifications are easier to make
from a central location than having code generated by behaviors placed in many areas around
your FLA file. Debugging and interaction can be inelegant or difficult with scattered code, and
sometimes it is easier to write the ActionScript yourself.
The main difference between a FLA file with behaviors and a FLA file without behaviors is the
workflow you must use for editing the project. If you use behaviors, you must select each instance
on the Stage, or select the Stage, and open the Actions or Behaviors panel to make modifications.
If you write your own ActionScript and put all your code on the main Timeline, you only have to
go to the Timeline to make your changes.
Use behaviors consistently throughout a document when they are your main or only source of
ActionScript. It is best to use behaviors when you have little or no additional code in the FLA file,
or have a consistent system in place for managing the behaviors that you use.