User Guide
ActionScript coding standards 93
Using return statements
Do not use parentheses [()]with any return statements that have values. The only time you
should use parentheses with
return statements is when it makes the value more obvious, which is
shown in the third line of the following ActionScript:
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 includes a break statement to
prevent a fall-through error if another case is added. For example, if the condition in the following
example evaluates to
A, both the statements for case A and B execute, because case A lacks a break
statement. The
default case should also be the last case in the switch statement. When a case
falls through, it does not have a
break statement, but includes a comment in the break
statement’s place, which you can see in the following example after
case A. Write switch
statements using the following format:
switch (condition) {
case A :
//statements
//falls through
case B :
//statements
break;
case Z :
//statements
break;
default :
//statements
break;
}
Using try-catch and try-catch-finally statements
Write try-catch and try-catch-finally statements using the following formats:
//try-catch
try {
//statements
} catch (myError) {
//statements
}
//try-catch-finally
try {
//statements
} catch (myError) {
//statements
} finally {
//statements
}