true constant

A unique Boolean value that represents the opposite of false. When automatic data typing converts true to a number, it becomes 1; when it converts true to a string, it becomes "true".

Example

The following example shows the use of true in an if statement:

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

The following example shows how automatic data typing converts true to the number 1:

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

See also

false constant, Boolean