User Guide

108 Chapter 3: Using Best Practices
Like the Behaviors guidelines, there are issues with how to organize and structure projects built
with the screen-based authoring environment. Screens provide an intelligent and easy to use
framework to control loading, persistence of data, and state using classes.
Some developers build applications with all their ActionScript in a centralized location. Other
designers and developers, usually newer to Flash, might use a more visual approach to writing a
screens document. Code placement is a central issue with screens and is discussed in this section.
For more information, see the following topics:
“Organizing code for screens” on page 108
“Working with other structural elements” on page 110
Organizing code for screens
There are three places you can place code in a screen-based application:
On the Timeline
On screens and symbol instances
In an external file
Because code can be placed in many different locations, it complicates matters as to where you
should put your code. Therefore, you must consider the type of application youre writing and
what it requires in the way of ActionScript. As with behaviors, you should use ActionScript
consistently in screen-based applications.
The difference between screens and behaviors is that the ActionScript that behaviors add is much
more complex than most of the behaviors available for a regular FLA file. Screens are based on
complex ActionScript, so some of the code used for transitions and changing slides might be
difficult to write yourself.
You might use either behaviors or ActionScript that attaches directly to screens, combined with
either a Timeline or an external ActionScript file. Even if you decentralize your code this way,
have code put on screens and an external ActionScript file, you should still avoid attaching code
directly to movie clip or button instances that are placed on individual screens. This ActionScript
is still hard to locate in a FLA file, debug, and edit.
Even if you attach code directly to a screen, it is more acceptable and easier to use than in regular
FLA files for the following reasons:
The code that attaches to screens when you use behaviors often doesnt interact with other
ActionScript you might write—you can place behaviors there and you might not have to worry
about editing the code further, which is ideal.
The code placed directly on screens is easy to locate and view the hierarchy of, because of the
Screen Outline pane. Therefore, it is easy to quickly locate and select all of the objects that you
might have attached ActionScript to.