264
Chapter 12: ActionScript Dictionary
This is because -1 decimal equals 11111111111111111111111111111111 binary (thirty-two
1’s), shifting right by one bit causes the least significant (bit farthest to the right) to be discarded
and the most significant bit to be filled in with 1. The result is
11111111111111111111111111111111 (thirty-two 1’s) binary, which represents the 32-bit
integer -1.
See also
>>= (bitwise right shift and assignment)
>>= (bitwise right shift and assignment)
Availability
Flash Player 5.
Usage
expression1
=>>
expression2
Parameters
expression1
A number or expression to be shifted left.
expression2
A number or expression that converts to an integer from 0 to 31.
Returns
Nothing.
Description
Operator (bitwise compound assignment); this operator performs a bitwise right-shift operation
and stores the contents as a result in
expression1
.
Example
The following two expressions are equivalent.
A >>= B
A = (A >> B)
The following commented code uses the bitwise (
>>=
)
operator. It is also an example of using all
bitwise operators.
function convertToBinary(number){
var result = "";
for (var i=0; i<32; i++) {
// Extract least significant bit using bitwise AND
var lsb = number & 1;
// Add this bit to our result string
result = (lsb ? "1" : "0") + result;
// Shift number right by one bit, to see next bit
number >>= 1;}
return result;
}
trace(convertToBinary(479));
// Returns the string 00000000000000000000000111011111
// The above string is the binary representation of the decimal
// number 479
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...