Player version: | Flash Player 5 — (became a native object in Flash Player 6, which improved performance significantly) |
The Boolean class is a wrapper object with the same functionality as the standard JavaScript Boolean object. Use the Boolean class to retrieve the primitive data type or string representation of a Boolean object.
You must use the constructor new Boolean()
to create a Boolean object before calling its methods.
public function Boolean([value:Object])
Player version: | Flash Player 5 |
Creates a Boolean object. If you omit the value
parameter, the Boolean object is initialized with a value of false
. If you specify a value for the value
parameter, the method evaluates it and returns the result as a Boolean value according to the rules in the global Boolean()
function.
Parameters
| value:Object [optional] — Any expression. The default value is false . |
Example
The following code creates a new empty Boolean object called
myBoolean
:
var myBoolean:Boolean = new Boolean();
public function toString():String
Player version: | Flash Player 5 |
Returns the string representation ("true"
or "false"
) of the Boolean object.
Returns
| String —
A string; "true" or "false" .
|
Example
This example creates a variable of type Boolean and then uses toString() to convert the value to a string for use in an array of strings:
var myStringArray:Array = new Array("yes", "could be");
var myBool:Boolean = 0;
myBool.toString();
myStringArray.push(myBool);
public function valueOf():Boolean
Player version: | Flash Player 5 |
Returns true
if the primitive value type of the specified Boolean object is true; false
otherwise.
Returns
Example
The following example shows how this method works, and also shows that the primitive value type of a new Boolean object is
false
:
var x:Boolean = new Boolean();
trace(x.valueOf()); // false
x = (6==3+3);
trace(x.valueOf()); // true
© 2004-2010 Adobe Systems Incorporated. All rights reserved.
Wed Apr 7 2010, 4:41 PM GMT-07:00