A while statement can be used even when the number of times is unknown.
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var nIndex:Number = 0;
var aValues:Array = [1,2,3];
while(aValues[nIndex] != null && nIndex < aValues.length) {
trace(aValues[nIndex]);
nIndex++;
}
for(var i:Number = 0; i < aValues.length; i++) {
if(aValues[i] == null) {
break;
}
trace(aValues[i]);
}
}
}
}
1
2
3
1
2
3
Related examples in the same category