MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual page 95

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

Following general formatting guidelines
Adding spacing (or white space) to your syntax is recommended because it makes your
ActionScript easier to read. The following formatting points are recommended to help promote
readability in your ActionScript.
The following example includes a space after a keyword that is followed by parentheses [()]:
do {
//something
} while (condition);
You do not have to put a space between a method name and a following parentheses, as the
following example shows:
function checkLogin() {
//statements;
}
checkLogin();
If you follow these guidelines, it is easier to distinguish between method calls and keywords.
In a list of arguments, such as in the following example, include a space after commas:
function addItems(item1:Number, item2:Number):Number {
return (item1+item2);
}
var sum:Number = addItems(1, 3);
Separate all operators and their operands by spaces, as the following ActionScript shows:
var sum:Number = 7 + 3;
An exception to this guideline is the dot (
decrement (--) do not have spaces.
Using scope
Scope is the area where the variable is known and can be used in a SWF file, such as on the
timeline, globally across an application, or locally within a function. There are three kinds of
variables: local, timeline, and global. For information on these variables and scope, see
and declaring variables" on page
static variable scopes.
It is important to understand the difference between the
scope is unique for each loaded SWF file. Use the
classes, or variables. The global scope applies to all Timelines and scopes within SWF files. Use
relative addressing rather than references to
portable. See the following sections for the recommended way of scoping variables. For more
information on scope, see
on page
176. For information on using the
For more information on scope, see the following sections:
"Avoiding _root" on page 96
"Using _lockroot" on page 96
) operator. Unary operators such as increment (++) and
.
45. ActionScript 2.0 classes also support public, private, and
_root
"Event handler scope" on page 174
super
and
_global
_root
identifier to create global objects,
_global
timelines, because it makes code reusable and
and
"Scope of the this keyword"
prefix, see
"Using the super prefix" on page
ActionScript coding standards
"Scoping
scopes. The
_root
87.
95

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents