Boolean


Object   |   +-Boolean public class Boolean extends Object

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.

Availability: ActionScript 1.0; Flash Player 5 - (became a native object in Flash Player 6, which improved performance significantly)

Property summary

Properties inherited from class Object

constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property)


Constructor summary

Signature

Description

Boolean([value:Object])

Creates a Boolean object.


Method summary

Modifiers

Signature

Description

 

toString() : String

Returns the string representation ("TRue" or "false") of the Boolean object.

 

valueOf() : Boolean

Returns true if the primitive value type of the specified Boolean object is true; false otherwise.


Methods inherited from class Object

addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method)


Boolean constructor

public Boolean([value:Object])

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.

Availability: ActionScript 1.0; Flash Player 5

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();

toString (Boolean.toString method)

public toString() : String

Returns the string representation ("true" or "false") of the Boolean object.

Availability: ActionScript 1.0; Flash Player 5

Returns

String - A string; "TRue" or "false".

Example

This example creates a variable of type Boolean and uses toString() to convert the value to a string for use in the trace statement:

var myBool:Boolean = true; trace("The value of the Boolean myBool is: " + myBool.toString()); myBool = false; trace("The value of the Boolean myBool is: " + myBool.toString());

valueOf (Boolean.valueOf method)

public valueOf() : Boolean

Returns TRue if the primitive value type of the specified Boolean object is true; false otherwise.

Availability: ActionScript 1.0; Flash Player 5

Returns

Boolean - A Boolean value.

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



ActionScript 2.0 Language Reference for Macromedia Flash 8
ActionScript 2.0 Language Reference for Macromedia Flash 8
ISBN: 0321384040
EAN: 2147483647
Year: 2004
Pages: 113

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net