Flash Lite 1.x ActionScript Language Reference |
|
|
|
| Flash Lite Operators > ++ (increment) | |||
Flash Lite 1.0.
++expressionexpression++
None.
Operator (arithmetic); a pre-increment and post-increment unary operator that adds 1 to expression. The expression can be a variable, element in an array, or property of an object. The pre-increment form of the operator (++expression) adds 1 to expression and returns the result as a number. The post-increment form of the operator (expression++) adds 1 to expression and returns the initial value of expression (the value before the addition).
The following example uses ++ as a post-increment operator to make a while loop run five times:
i = 0;
while (i++ < 5){
trace("this is execution " + i);
}
The following example uses ++ as a pre-increment operator:
a = "";
i = 0;
while (i < 10) {
a = a add (++i) add ",";
}
trace(a); // output: 1,2,3,4,5,6,7,8,9,10,
This script shows the following result in the Output panel:
1,2,3,4,5,6,7,8,9,10,
The following example uses ++ as a post-increment operator:
a = "";
i = 0;
while (i < 10) {
a = a add (i++) add ",";
}
trace(a); // output: 0,1,2,3,4,5,6,7,8,9,
This script shows the following result in the Output panel:
0,1,2,3,4,5,6,7,8,9,
|
|
|
|