EasyManua.ls Logo

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

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...
770 Best Practices and Coding Conventions for ActionScript 2.0
Writing while and do..while statements
You can write while statements using the following format:
while (condition) {
// statements
}
You can write do-while statements using the following format:
do {
// statements
} while (condition);
Writing return statements
Dont use parentheses [()] with any return statements that have values. The only time to use
parentheses with
return statements is when they make the value more obvious, as shown in
the third line of the following ActionScript code snippet:
return;
return myCar.paintColor;
// parentheses used to make the return value obvious
return ((paintColor)? paintColor: defaultColor);
Writing switch statements
All switch statements include a default case.
The default case is the last case in a
switch statement. The default case includes a break
statement that prevents a fall-through error if another case is added.
If a case does not have a break statement, the case will fall through (see case A in the
following code example).
Your statement should include a comment in the
break statements place, as you can see
in the following example after
case A. In this example, if the condition matches case A,
both cases A and B execute.

Table of Contents

Related product manuals