
Using operators to manipulate values in expressions
31
In the following example,
myArray
contains an Array object, so it is passed to function
zeroArray()
by reference. The function
zeroArray()
accepts an Array object as a parameter
and sets all the elements of that array to 0. It can modify the array because the array is passed by
reference.
function zeroArray (theArray:Array):Void {
var i:Number;
for (i=0; i < theArray.length; i++) {
theArray[i] = 0;
}
}
var myArray:Array = new Array();
myArray[0] = 1;
myArray[1] = 2;
myArray[2] = 3;
zeroArray(myArray);
trace(myArray); // 0,0,0
Using operators to manipulate values in expressions
An expression is any statement that Flash can evaluate and that returns a value. You can create an
expression by combining operators and values or by calling a function.
Operators are characters that specify how to combine, compare, or modify the values of an
expression. The elements that the operator performs on are called
operands
. For example, in the
following statement, the addition (
+)
operator adds the value of a numeric literal to the value of
the variable
foo
;
foo
and
3
are the operands:
foo + 3
This section describes general rules about common types of operators, operator precedence, and
operator associativity:
•
“Operator precedence and associativity” on page 32
•
“Numeric operators” on page 33
•
“Comparison operators” on page 34
•
“String operators” on page 35
•
“Logical operators” on page 36
•
“Bitwise operators” on page 36
•
“Equality operators” on page 37
•
“Assignment operators” on page 37
•
“Dot and array access operators” on page 38
For detailed information on these operators as well as special operators that don’t fall into these
categories, see
Chapter 5, “ActionScript Core Language Elements,” on page 80
.
Содержание 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...