EasyManua.ls Logo

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

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...
Naming conventions 737
Dont use variables that are parts of common programming constructs.
Dont use language constructs if you are aware of them in other programming languages,
even if Flash does not include or support these language constructs. For example, do not
use the following keywords as variables:
textfield = "myTextField";
switch = true;
new = "funk";
Always add data type annotations to your code.
Also referred to as “using strict data types with your variables,” or “strong typing your
variables,” adding type annotations to your variables is important in order to:
Generate errors at compile time so your application doesnt silently fail.
Trigger code completion.
Helps users understand your code.
For information on adding type annotations, see About assigning data types and strict
data typing” on page 81.
Dont overuse the Object type.
Data type annotations should be precise to improve performance. Use an Object type
only when there is no reasonable alternative.
Keep variables as short as possible while retaining clarity.
Make sure your variable names are descriptive, but dont go overboard and use overly
complex and long names.
Only use single-character variable names for optimization in loops.
Optionally, you can use single-character variables for temporary variables in loops (such as
i, j, k, m, and n). Use these single-character variable names only for short loop indexes, or
when performance optimization and speed are critical. The following example shows this
usage:
var fontArr:Array = TextField.getFontList();
fontArr.sort();
var i:Number;
for (i = 0; i<fontArr.length; i++) {
trace(fontArr[i]);
}
Start variables with a lowercase letter.
Names with capital first letters are reserved for classes, interfaces, and so on.
Use mixed case for concatenated words.
For example, use
myFont instead of myfont.

Table of Contents

Related product manuals