Flash ActionScript 3 Step Up For Loop Statement(1)
In this Flash ActionScript tutorial, the value of the variable increase by one with each loop, i.e. n, n+1, n+2, n+3, etc... until the looping ends.
Flash Tutorial Content:
Step Up For Loop with increasement of 1 is most commonly used in a For Loop Statement in Flash ActionScript. This is also the most basic For Loop Statement. The value of the variable increase by one with each loop.
The complete Flash Movie is shown as above, you may try how it works before you start this Flash tutorial.
Flash ActionScript Codes:
//Set the multiline parameter of the Text Field to true
//The <br> tag creates a line break in the Text Field.
//Must set the text field to be a multiline Text Field to use this tag.
output_txt.multiline = true;
//Declare a string to the data
//Also assign an empty value to this string (myString)
var myString:String = "";
//Declare i as an integer
//Execute the For Loop Statement
//A For Loop requires three expressions:
//a variable i is set to an initial value - zero
//a conditional determines when the looping ends - when i < 5
//an expression changes the value of the variable with each loop - i++ (increase by one)
for (i = 0; i < 5; i++)
//Display the string to Text Field
output_txt.htmlText = myString;
Structure of a For Loop Statement
Still wonder how the For Loop works? Let's recall the structure of a For Loop statement as below:
Download Flash Source File:
Hm..... Actually the variable can be increased by any step (e.g. 2, 3, 4, etc..). The next Flash ActionScript tutorial will show how to do that.