else if

可用性

Flash Lite 1.0。

用法

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

参数

condition 计算结果为 truefalse 的表达式。

statement 当 if 语句中指定的条件为 false 时要运行的一系列语句。

说明

语句;计算条件,并指定当初始 if 语句中的条件返回 false 值时要运行的语句。如果 else if 条件返回 true 值,则 Flash 解释程序运行 else if 条件后面大括号 ({}) 中的语句。如果 else if 条件为 false,则 Flash 将跳过大括号中的语句,而运行大括号后面的语句。使用 else if 语句可在脚本中创建分支逻辑。

示例

以下示例使用 else if 语句检查对象的每一边是否都在特定的边界内:

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");
}

另请参见

if