Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Step Down For Loop with Flash ActionScript 3 Code

In previous For Loop Flash ActionScript tutorials, we only use Step Up For Loops. Is it possible to use Step Down For Loop, i.e. the variable decrease with each loop? Yes. This Flash ActionScript tutorial shows how to do that.

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Sometimes you may require the value of the variable decrease by any amount with each loop. The rule is of a Step Down For Loop is same as Step Up For Loop in Flash ActionScript. Instead of writing an expression increase the value of the variable with each loop (e.g. i++, i=i+2, etc..), we write an expression decrease the value of the variable with each loop (e.g. i--, i=i-2, etc..)

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
var i:int;


//Execute the For Loop Statement
//A For Loop requires three expressions:
//a variable i is set to an initial value - 5
//a conditional determines when the looping ends - when i >0
//an expression changes the value of the variable with each loop - i-- (decrease by one)
for (i = 5; i > 0; i--)

myString = myString + "The value of i is: " + i + "<BR>";



//Display the string to Text Field
output_txt.htmlText = myString;

Download Flash Source File:

Flash Source File for-loop-3.fla


For Loop is a very powerful statement. You should find at least one For Loop in any complicated program. This Flash ActionScript tutorial shows how to use a Step Down For Loop statement.