In the following example,
by reference. The function
zeroArray()
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 (
the variable
;
foo
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
contains an Array object, so it is passed to function
myArray
operator adds the value of a numeric literal to the value of
+)
and
are the operands:
foo
3
accepts an Array object as a parameter
zeroArray()
Using operators to manipulate values in expressions
80.
31
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?