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
statement. For example, in the following script, if both expressions are true, the
execute and the
if (i > 10 && i <50){
myFunc(i);
}
Consider the order of operands, especially if you're setting up complex conditions and you know
how often one condition is true compared with other conditions. In the previous example, if you
know that, in most cases,
condition
will be checked first, and the second condition doesn't need to be checked in most
i<50
cases.
The following table lists the ActionScript logical operators:
Operator
Operation performed
Logical AND: Returns
&&
Logical OR: Returns
||
!operand
Logical NOT: Returns the logical (Boolean) opposite of the operand. The logical NOT
operator takes one operand.
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
36
Chapter 1: ActionScript Basics
function will be called:
myFunc()
will be greater than 50, consider putting the condition
i
true
true
and
) and return a third Boolean value.
true
false
, the logical AND (
true
, the logical OR (
true
only if both the left and right operands are true.
if either the left or right operand is true.
) operator returns
&&
) operator returns
||
true
statement will
if
i<50
. If
true
. Logical
if
first; the
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?