The while loop is like an if statement that repeats as long as the condition is true. For example, the following code produces the same output as the for loop example.
var i:int = 0;
while (i < 5) {
trace (i);
i++;
}
One disadvantage of using a while loop instead of a for loop is that infinite loops are easier to write with while loops. The for loop example code does not compile if you omit the expression that increments the counter variable, but the while loop example does compile if you omit that step. Without the expression that increments i, the loop becomes an infinite loop.