else if

Availability

Flash Lite 1.0.

Usage

if (condition){
    statement(s);
} else if (condition){
    statement(s);
}

Parameters

condition An expression that evaluates to true or false.

statement(s) A series of statements to run if the condition specified in the if statement is false.

Description

Statement; evaluates a condition and specifies the statements to run if the condition in the initial if statement returns a false value. If the else if condition returns a true value, the Flash interpreter runs the statements that follow the else if condition inside curly braces ({}). If the else if condition is false, Flash skips the statements inside the curly braces and runs the statements following the curly braces. Use the else if statement to create branching logic in your scripts.

Example

The following example uses else if statements to check whether each side of an object is within a specific boundary:

person_mc.xPos = 100;
leftBound = 0;
rightBound = 100;
if (person_mc.xPos <= leftBound) {
    //trace ("Clip is to the far left");
} else if (person_mc.xPos >= rightBound) {
    //trace ("Clip is to the far right");    
} else {
    //trace ("Your clip is somewhere in between");
}

See also

if