96
Chapter 5: ActionScript Core Language Elements
Parameters
None.
Returns
The value of
expression1
,
expression2
, and so on.
Description
Operator; evaluates
expression1
, then
expression2
, and so on. This operator is primarily used
with the
for
loop statement and is often used with the parentheses () operator.
For more information, see
“Operator precedence and associativity” on page 32
.
Example
The following example uses the comma (,) operator in a
for
loop:
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
The following example uses the comma (,) operator without the parentheses () operator and
illustrates that the comma operator sequentially evaluates all of the expressions but returns the
value of the first expression. The second expression,
z++
, is evaluated and
z
is incremented by
one.
var v:Number = 0;
var z:Number = 0;
v = v + 4 , z++, v + 6;
trace(v); // output: 4
trace(z); // output: 1
The following example is identical to the previous example except for the addition of the
parentheses () operator and illustrates once again that, when used with the parentheses () operator,
the comma (,) operator returns the value of the last expression in the series:
var v:Number = 0;
Содержание FLEX
Страница 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 ...