Learning ActionScript 2.0 in Adobe Flash |
|
|
|
| Best Practices and Coding Conventions for ActionScript 2.0 > Formatting ActionScript syntax > Writing switch statements | |||
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.
case A in the following code example).
Your statement should include a comment in the break statement's 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.
You can 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;
}
|
|
|
|