User Guide
Conditionals 85
Conditionals
ActionScript 3.0 provides three basic conditional statements that you can use to control
program flow.
if..else
The if..else conditional statement allows you to test a condition and execute a block of
code if that condition exists, or execute an alternative block of code if the condition does not
exist. For example, the following code tests whether the value of
x exceeds 20, generates a
trace() function if it does, or generates a different trace() function if it does not:
if (x > 20)
{
trace("x is > 20");
}
else
{
trace("x is <= 20");
}
If you do not want to execute an alternative block of code, you can use the if statement
without the
else statement.