EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Actionscript Coding Conventions

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...
ActionScript coding conventions 745
Use block, single-line, and trailing comments within the body of your class to comment on
your ActionScript code. For more information on using comments in class files, see “Adding
comments to classes” on page 744.
ActionScript coding conventions
One of the most important aspects about programming is consistency, whether it relates to
variable naming schemes (covered in “Naming conventions” on page 732), formatting code
(covered in “Formatting ActionScript syntax” on page 764), or coding standards and the
placement of your ActionScript 2.0 code, which is covered in this section. You dramatically
simplify code debugging and maintenance if your code is organized and adheres to standards.
For more information on coding conventions, see the following topics:
“Keeping your ActionScript code in one place” on page 745
Attaching code to objects” on page 746
“Handling scope” on page 747
“Structuring a class file” on page 751
About using functions” on page 760
Keeping your ActionScript code in one place
Whenever possible, put your ActionScript 2.0 code in a single location, such as in one or
more external ActionScript files or on Frame 1 of the Timeline (when placed on the timeline,
the code is called a frame script).
If you put your ActionScript code in a frame script, put the ActionScript code on the first or
second frame on the Timeline, in a layer called Actions, which is the first or second layer on
the Timeline. Sometimes you might create two layers—an acceptable practice—for
ActionScript to separate functions. Some Flash applications do not always put all your code in
a single place (in particular, when you use screens or behaviors).
Despite these rare exceptions, you can usually put all your code in the same location. The
following are the advantages of placing your ActionScript in a single location:
Code is easy to find in a potentially complex source file.
Code is easy to debug.

Table of Contents

Related product manuals