Loops
Looping statements are control structures that allow you to perform a specific block of code repeatedly using a series of values or variables until a certain condition is reached.
Link to Adobe references to Looping in AS 3.0 HERE
Looping statements are control structures that allow you to perform a specific block of code repeatedly using a series of values or variables until a certain condition is reached.
Link to Adobe references to Looping in AS 3.0 HERE
The for statement has 3 parts: the initial statement, a condition and a change statement (see lines 1, 2 and 3 of the code below). | ||||||||||||||||||||||||||||||||||||||||||||||
|
for (var i: int = 0 ; i < 10; i ++) { The code will loop and add 1 time each time it runs until thevalue of the variable i is 10, then it will run the function doSomething. |
You can use the break command to exit the loop at any time.
The continue command skips the rest of the lines of code in the loop and begins the next iteration through the loop.
The while statement produces a loop that continues for ever as long as an initial statement (after the while) is met. |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|
var i: int = 0 ; The code will loop and add 1 time each time it runs until the value of the variable i is 10. |
A do loop is a variation of a while loop. The conditional statement comes AFTER the loop,ensuring that executes at least once. |
||||||||||||||||||||||||||||||||||||||||
|
var i: int = 0 ;
|