, comma operator
(expression1 , expression2 [, expressionN... ])
Evaluates
expression1
the
loop statement and is often used with the parentheses () operator.
for
Availability: ActionScript 1.0; Flash Player 4
Operands
expression1 : Number
expression2 : Number
expressionN : Number
Returns
- The value of
Object
Example
The following example uses the comma (,) operator in a
for (i = 0, j = 0; i < 3 && j < 3; i++, j+=2) {
trace("i = " + i + ", j = " + j);
}
// Output:
// i = 0, j = 0
// i = 1, j = 2
The following example uses the comma (,) operator without the parentheses () operator and
illustrates that the comma operator returns only the value of the first expression without the
parentheses () operator:
var v:Number = 0;
v = 4, 5, 6;
trace(v); // output: 4
The following example uses the comma (,) operator with the parentheses () operator and
illustrates that the comma operator returns the value of the last expression when used with the
parentheses () operator:
var v:Number = 0;
v = (4, 5, 6);
trace(v); // output: 6
, then
expression2
- An expression to be evaluated.
- An expression to be evaluated.
- Any number of additional expressions to be evaluated.
,
expression1
expression2
, and so on. This operator is primarily used with
, and so on.
loop:
for
Operators
153
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?