However, placing the equivalent ActionScript code on a timeline appears as follows:
// good code
myBtn.onRelease = function() {
// Do something.
};
For more information on ActionScript syntax, see
on page
764.
Using behaviors and screens sometimes involves attaching code to objects, so different
practices apply when you use these features. For more information, see
"Best practices for using behaviors"
Handling scope
Scope is the area where the variable is known and can be used in a SWF file, such as on a
timeline, globally across an application, or locally within a function. Typically, you can
reference scope in more than one way when you write code. Using scope correctly means that
you can create portable and reusable ActionScript code, and you don't risk breaking your
applications as you build new modules.
It is important to understand the difference between the global and root scopes. The root
scope is unique for each loaded SWF file. The global scope applies to all timelines and scopes
within SWF files. You use relative addressing rather than references to root timelines, because
relative addressing makes your code reusable and portable. For more information on handling
scope in your applications, see the following sections:
"About variables and scope" on page 96
"About scope and targeting" on page 123
"Understanding classes and scope" on page
"Formatting ActionScript syntax"
in Using Flash.
283.
ActionScript coding conventions
Chapter 3,
747
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?