Don't use variables that are parts of common programming constructs.
Don't 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 doesn't silently fail.
Trigger code completion.
Helps users understand your code.
For information on adding type annotations, see
data typing" on page
Don't 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 don't 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
,
,
,
, and
). Use these single-character variable names only for short loop indexes, or
i
j
k
m
n
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
81.
instead of
myfont
"About assigning data types and strict
.
Naming conventions
737
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?