Align the second line with the start of the expression on the previous line of code.
You can control auto-indentation and indentation settings by selecting Edit >
Preferences (Windows) or Flash > Preferences (Macintosh), and then selecting the
ActionScript tab.
Writing conditional statements
Use the following guidelines when you write conditional statements:
Place conditions on separate lines in
Use braces (
) for
{}
Format braces as shown in the following examples:
// if statement
if (condition) {
// statements
}
// if..else statement
if (condition) {
// statements
} else {
// statements
}
// else..if statement
if (condition) {
// statements
} else if (condition) {
// statements
} else {
// statements
}
When you write complex conditions, it is good form to use parentheses [()] to group
conditions. If you don't use parentheses, you (or others working with your ActionScript 2.0
code) might run into operator precedence errors.
For example, the following code does not use parentheses around the conditions:
if (fruit == apple && veggie == leek) {}
The following code uses good form by adding parentheses around conditions:
if ((fruit == apple) && (veggie == leek)) {}
,
if
statements.
if
, and
else..if
if..else
Formatting ActionScript syntax
statements.
767
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?