EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 197

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
About operators 197
About bitwise logical operators
The bitwise logical operators take two operands and perform bit-level logical operations. The
bitwise logical operators differ in precedence and are listed in the table in order of decreasing
precedence:
For information on using bitwise operators, see “Using bitwise operators” on page 197. For
specific information on each bitwise operator, see its entry in the ActionScript 2.0 Language
Reference.
Using 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. For
a list of bitwise shift operators, see About bitwise shift operators” on page 196. For a list of
bitwise logical operators, see About bitwise logical operators on page 197.
Using bitwise operators in Flash isnt very common, but can be useful in some circumstances.
For example, you might want to build a permissions matrix for a Flash project, but you dont
want to create separate variables for each type of permission. In this case, you might use
bitwise operators.
The following example shows how you can use the bitwise OR operator with the
Array.sort() method to specify sort options.
To use the bitwise OR operator:
1. Select File > New and create a new Flash document.
2. Type the following ActionScript into the Actions panel:
var myArr:Array = new Array("Bob", "Dan", "doug", "bill", "Hank",
"tom");
trace(myArr); // Bob,Dan,doug,bill,Hank,tom
myArr.sort(Array.CASEINSENSITIVE | Array.DESCENDING);
trace(myArr); // tom,Hank,doug,Dan,Bob,bill
Operator Operation performed
&
Bitwise AND
^
Bitwise XOR
|
Bitwise OR

Table of Contents

Related product manuals