| Package | Top Level |
| Class | public final class Boolean |
| Inheritance | Boolean Object |
true or false.
Used for logical operations. Use the Boolean
class to retrieve the primitive data type or string representation of a Boolean object.
It makes no difference whether you use the constructor, the global function, or simply assign a literal value. The fact that all three ways of creating a Boolean are equivalent is new in ActionScript 3.0, and different from a Boolean in JavaScript where a Boolean object is distinct from the Boolean primitive type.
The following lines of code are equivalent:
var flag:Boolean = true; var flag:Boolean = new Boolean(true); var flag:Boolean = Boolean(true);
| Function | Defined by | ||
|---|---|---|---|
|
Creates a
Boolean object with the specified value . | Boolean | ||
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
|
Returns the string representation (
"true" or
"false") of the Boolean object. | Boolean | ||
|
Returns
true if the value of the specified Boolean
object is true; false otherwise. | Boolean | ||
public function Boolean(expression:Object = false)
Boolean object with the specified value . If you omit the expression
parameter, the Boolean object is initialized with a value of false. If you
specify a value for the expression parameter, the method evaluates it and returns the result
as a Boolean value according to the rules in the global Boolean() function.
Parameters
expression:Object (default = false) — Any expression. The default value is false.
|
false called myBoolean:
var myBoolean:Boolean = new Boolean();
| Boolean() |
public function toString():String
"true" or
"false") of the Boolean object. The output is not localized, and will be "true" or
"false" regardless of the system language.
Returns
String —
A string; "true" or "false".
|
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
true if the value of the specified Boolean
object is true; false otherwise.
Returns
Boolean —
A Boolean value.
|
false:
var myBool:Boolean = new Boolean(); trace(myBool.valueOf()); // false myBool = (6==3+3); trace(myBool.valueOf()); // true
package {
import flash.display.Sprite;
public class BooleanExample extends Sprite {
private var flag:Boolean;
public function BooleanExample() {
trace(flag); // false
toggle();
trace(flag); // true
toggle();
trace(flag); // false
}
private function toggle():void{
flag = !flag;
}
}
}