Logical operators
Logical operators compare Boolean values (
For example, if both operands evaluate to
one or both of the operands evaluate to
operators are often used with comparison operators to determine the condition of an
For example, in the following script, if both expressions are true, the
if (i > 10 && _framesloaded > 50){
play();
}
The following table lists the ActionScript logical operators:
Operator
Operation performed
&&
Logical AND
Logical OR
||
Logical NOT
!
Bitwise operators
Bitwise operators internally manipulate floating-point numbers to change them into 32-bit
integers. The exact operation performed depends on the operator, but all bitwise operations
evaluate each binary digit (bit) of the 32-bit integer individually to compute a new value.
The following table lists the ActionScript bitwise operators:
Operator
Operation performed
&
Bitwise AND
|
Bitwise OR
^
Bitwise XOR
~
Bitwise NOT
<<
Shift left
>>
Shift right
>>>
Shift right zero fill
Equality operators
You can use the equality (
operands are equal. This comparison returns a Boolean (
strings, numbers, or Boolean values, they are compared by value. If the operands are objects or
arrays, they are compared by reference.
It is a common mistake to use the assignment operator to check for equality. For example, the
following code compares x to 2:
if (x == 2)
In that same example, the expression
it assigns the value of 2 to the variable
true
, the logical AND operator (
true
, the logical OR operator (
true
) operator to determine whether the values or identities of two
==
is incorrect because it doesn't compare the operands,
x = 2
.
x
Using operators to manipulate values in expressions
and
) and return a third Boolean value.
false
if
or
) value. If the operands are
true
false
) returns
. If
&&
true
) returns
. Logical
||
true
action.
if
action will execute:
47
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?
Questions and answers