MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference page 151

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

Example
The following example uses ++ as a post-increment operator to make a
times:
var i:Number = 0;
while (i++ < 5) {
trace("this is execution " + i);
}
/* output:
this is execution 1
this is execution 2
this is execution 3
this is execution 4
this is execution 5
*/
The following example uses ++ as a pre-increment operator:
var a:Array = new Array();
var i:Number = 0;
while (i < 10) {
a.push(++i);
}
trace(a.toString()); //traces: 1,2,3,4,5,6,7,8,9,10
This example also uses ++ as a pre-increment operator.
var a:Array = [];
for (var i = 1; i <= 10; ++i) {
a.push(i);
}
trace(a.toString()); //traces: 1,2,3,4,5,6,7,8,9,10
This script shows the following result in the Output panel:
following example uses ++ as a post-increment operator in a
// using a while loop
var a:Array = new Array();
var i:Number = 0;
while (i < 10) {
a.push(i++);
}
trace(a.toString()); //traces 0,1,2,3,4,5,6,7,8,9
The following example uses ++ as a post-increment operator in a
// using a for loop
var a:Array = new Array();
for (var i = 0; i < 10; i++) {
a.push(i);
}
trace(a.toString()); //traces 0,1,2,3,4,5,6,7,8,9
loop run five
while
1,2,3,4,5,6,7,8,9,10
loop:
while
loop:
for
Operators
The
151

Advertisement

Table of Contents
loading

Table of Contents