EasyManua.ls Logo

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

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...
Formatting ActionScript syntax 767
Align the second line with the start of the expression on the previous line of code.
Writing conditional statements
Use the following guidelines when you write conditional statements:
Place conditions on separate lines in if, else..if, and if..else statements.
Use braces ({}) for if statements.
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 dont 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)) {}
NOTE
You can control auto-indentation and indentation settings by selecting Edit >
Preferences (Windows) or Flash > Preferences (Macintosh), and then selecting the
ActionScript tab.

Table of Contents

Related product manuals