112
Chapter 5: ActionScript Core Language Elements
Parameters
expression
A
number.
Returns
A 32-bit integer.
Description
Operator (bitwise); also known as the one’s complement operator or the bitwise complement
operator. Converts the
expression
to a 32-bit signed integer, and then applies a bitwise one’s
complement. That is, every bit that is a 0 is set to 1 in the result, and every bit that is a 1 is set to
0 in the result. The result is a signed 32-bit integer.
For example, the hex value 0x7777 is represented as this binary number:
0111011101110111
The bitwise negation of that hex value, ~0x7777, is this binary number:
1000100010001000
In hexadecimal, this is 0x8888. Therefore, ~0x7777 is 0x8888.
The most common use of bitwise operators is for representing
flag bits
(Boolean values packed
into 1 bit each).
Floating-point numbers are converted to integers by discarding any digits after the decimal point.
Positive integers are converted to an unsigned hex value with a maximum value of 4294967295 or
0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when
they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hex
value via the two’s complement notation, with the minimum being -2147483648 or
0x800000000; numbers less than the minimum are converted to two’s complement with greater
precision and also have the most significant digits discarded.
The return value is interpreted as a two’s complement number with sign, so the return value is an
integer in the range -2147483648 to 2147483647.
For more information, see
“Operator precedence and associativity” on page 32
.
Example
The following example demonstrates a use of the bitwise NOT (-) operator with flag bits:
var ReadOnlyFlag:Number = 0x0001;
// defines bit 0 as the read-only flag
var flags:Number = 0;
trace(flags);
/* To set the read-only flag in the flags variable, the following code uses the
bitwise OR: */
flags |= ReadOnlyFlag;
trace(flags);
Содержание FLEX-FLEX ACTIONSCRIPT LANGUAGE
Страница 1: ...Flex ActionScript Language Reference...
Страница 8: ......
Страница 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Страница 76: ......
Страница 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Страница 135: ...case 135 See also break default strict equality switch...
Страница 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Страница 229: ...while 229 i 3 The following result is written to the log file 0 3 6 9 12 15 18 See also do while continue for for in...
Страница 808: ...808 Chapter 7 ActionScript for Flash...
Страница 810: ...810 Appendix A Deprecated Flash 4 operators...
Страница 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Страница 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Страница 822: ...822 Index...