true 常数

一个表示与 false 相反的唯一布尔值。如果自动设置数据类型将 true 转换为数字,则它变为 1;如果将 true 转换为字符串,则它变为 "true"

示例

下面的示例说明 trueif 语句中的使用情况:

var shouldExecute:Boolean;
// ...
// code that sets shouldExecute to either true or false goes here
// shouldExecute is set to true for this example:

shouldExecute = true;

if (shouldExecute == true) {
 trace("your statements here");
}

// true is also implied, so the if statement could also be written:
// if (shouldExecute) {
// trace("your statements here");
// }

下面的示例说明自动设置数据类型如何将 true 转换为数字 1:

var myNum:Number;
myNum = 1 + true;
trace(myNum); // output: 2

请参阅

false 常数, Boolean