ActionScript 2.0 语言参考 |
|
|
|
| ActionScript 语言元素 > 常数 > true 常数 | |||
一个表示与 false 相反的唯一布尔值。当自动数据类型指定将 true 转换为数字时,它变为 1;将 true 转换为字符串时,它变为 "true"。
可用性:ActionScript 1.0、Flash Player 5
下面的示例演示 true 在 if 语句中的用法:
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
|
|
|
|