and

可用性

Flash Lite 1.0。

用法

condition1 and condition2

操作数

condition1、condition2 计算结果为 true 或 false 的条件或表达式。

说明

运算符;执行逻辑 AND 运算。

示例

以下示例使用 and 运算符测试游戏者是否在游戏中获胜。在游戏过程中,当游戏者赢得一轮或者得到计分点时,就会对 turnsscore 变量进行更新。在 3 轮之内游戏者的得分达到或超过 75 时,下面的脚本就会在"输出"面板中显示 "You Win the Game!"(您获得了游戏的胜利!)。

turns = 2;
score = 77;
winner = (turns <= 3) and (score >= 75);
if (winner) {
    trace("You Win the Game!");
} else {
    trace("Try Again!");
}
// 输出:You Win the Game!

另请参见

&&(逻辑 AND)