EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 734

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 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...
734 Best Practices and Coding Conventions for ActionScript 2.0
General naming guidelines
This section reviews naming guidelines for writing ActionScript code. Naming conventions
are important for writing logical code. The primary purpose is to improve the readability of
your ActionScript 2.0 code. Remember that all variables must have unique names. Names are
case-sensitive in Flash Player 7 and later. Do not use the same name with a different case,
because this can be confusing to programmers reading your code and can cause problems in
earlier versions of Flash that do not force case sensitivity. Keep the following guidelines in
mind when you name items such as variables, files, and classes in Flash:
Limit your use of abbreviations.
Use abbreviations consistently. An abbreviation must clearly stand for only one thing. For
example, the abbreviation “sec” might represent “section” and “second.
Concatenate words to create names.
Use mixed-cases (upper and lower case) when you concatenate words to distinguish
between each word for readability. For example, select
myPelican rather than
mypelican
.
Name a file by describing the process or item, such as addUser.
Dont use nondescriptive names for methods or variables.
For example, if you retrieve a piece of data that is the visitors user name, you might use
the
getUserName() method instead of the less descriptive getData() method. This
example expresses what is happening rather than how you accomplish it.
Keep all names as short as possible.
Remember to keep names descriptive.
The following sections offer more detail on naming items such as variables, classes, packages,
and constants in your code.
Avoiding reserved words or language constructs
When naming instances and variables, avoid using reserved words, which can cause errors in
your code. Reserved words include keywords in the ActionScript language.
Also, do not use any word in the ActionScript 2.0 languages (called a language construct) as an
instance or variable name. ActionScript constructs include class names, component class
names, method and property names, and interface names.
WARNING
Never use different cases to avoid conflicting with reserved words. For example, naming
an instance of the
textfield TextField class (which doesn’t conflict with TextField
because Flash is case-sensitive) is a poor coding practice.

Table of Contents

Related product manuals