Flash Lite 2 |
|||
| Flash Lite 2.x ActionScript Language Reference > ActionScript language elements > Statements > else statement | |||
if (condition){ statement(s); } else { statement(s); }
Specifies the statements to run if the condition in the if statement returns false. The curly braces ({}) used to enclose the block of statements to be executed by the else statement are not necessary if only one statement will execute.
Availability: ActionScript 1.0; Flash Lite 1.0
condition:Boolean - An expression that evaluates to true or false.
In the following example, the else condition is used to check whether the age_txt variable is greater than or less than 18:
if (age_txt.text>=18) { trace("welcome, user"); } else { trace("sorry, junior"); userObject.minor = true; userObject.accessAllowed = false; }
In the following example, curly braces ({}) are not necessary because only one statement follows the else statement:
if (age_txt.text>18) { trace("welcome, user"); } else trace("sorry, junior");