User Guide

54 Chapter 2: ActionScript Basics
Consider the order of operands, especially if youre 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,
i will be greater than 50, consider putting the condition i<50 first; the
condition
i<50 will be checked first, and the second condition doesnt need to be checked in most
cases.
The following table lists the ActionScript logical operators:
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:
Equality operators
You can use the equality (
==) operator to determine whether the values or references of two
operands are equal. This comparison returns a Boolean (
true or false) value. If the operands are
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 if (x = 2) would be incorrect, because it doesnt compare
the operands; it assigns the value of 2 to the variable
x.
Operator Operation performed
&&
Logical AND: Returns true only if both the left and right operands are true.
||
Logical OR: Returns true if either the left or right operand is true.
!operand Logical NOT: Returns the logical (Boolean) opposite of the operand. The logical NOT
operator takes one operand.
Operator Operation performed
&Bitwise AND
|Bitwise OR
^Bitwise XOR
~Bitwise NOT
<< Shift left
>> Shift right
>>> Shift right zero fill