40
ActionScript language elements
Example
trace(Boolean(-1)); // output: true
trace(Boolean(0)); // output: false
trace(Boolean(1)); // output: true
trace(Boolean(true)); // output: true
trace(Boolean(false)); // output: false
trace(Boolean("true")); // output: true
trace(Boolean("false")); // output: true
trace(Boolean("Craiggers")); // output: true
trace(Boolean("")); // output: false
If files are published for Flash Player 6 and earlier, the results 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 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
call function
call(
frame
)
Deprecated
since Flash Player 5. This action was deprecated in favor of the
function
statement.
Summary of Contents for Flash Lite 2
Page 1: ...Flash Lite 2 x ActionScript Language Reference...
Page 22: ...22 Contents...
Page 244: ...244 ActionScript language elements...
Page 760: ...760 ActionScript classes...