User Guide
Boolean() 127
If files are published for Flash Player 6 or earlier, the results will differ for three of the preceding
examples:
trace(Boolean("true")); // output: false
trace(Boolean("false")); // output: false
trace(Boolean("Craiggers")); // output: false
This example shows a string that will evaluate as true if the file is published for Flash Player 7,
but will evaluate as
false for Flash Player 6 or earlier:
trace(Boolean("0"));
This example shows a significant difference between use of the Boolean() function and the
Boolean class. The
Boolean() function creates a Boolean value, and the Boolean class creates a
Boolean object. Boolean values are compared by value, and Boolean objects are compared by
reference.
// Variables representing Boolean values are compared by value
var a:Boolean = Boolean("a"); // a is true
var b:Boolean = Boolean(1); // b is true
trace(a==b); // true
// Variables representing Boolean objects are compared by reference
var a:Boolean = new Boolean("a"); // a is true
var b:Boolean = new Boolean(1); // b is true
trace(a==b); // false
See also
Boolean class