EasyManua.ls Logo

MACROMEDIA FLASH 8-USING FLASH - Page 99

MACROMEDIA FLASH 8-USING FLASH
678 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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.

Table of Contents

Related product manuals