Develop PHP Website for Learning Web Design Free Online
  Home   |   Forums   |   DevCMS
  Join   |   Log In
 
   

Actionscript 3.0 Tutorials - Learn Actionscript 3.0

Tutor at Develop PHP
Looping
By: Adam      Created: Jul 07, 2009      Views: 4701 Tweet This Page  Post page to Facebook  Post page to Facebook

Looping in ActionScript 3.0 has many uses in programming data flow and animations. For example, I have a Flash ActionScript 3.0 tutorial here on how to create event listeners for many buttons using a loop and a simple array. Looping is a great way for data programmers to automate the data flow and streamline code.

for loop

Using a for loop make code execute over and over as many times as needed. There are three expressions needed in the parenthesis. The first expression is the is the variable to be evaluated, the second expression in the operator evaluation, and the third expression increments or decrements the value.
Learn HTML
var i:uint;
for (i = 1; i <= 4; i++) {
    trace(i);
}

Develop PHP browser display window
1
2
3
4

for ( in ) loop
for ( in ) loops make it possible to iterate through arrays of information or objects.
Learn HTML
var myArray:Array = ["France", "Great Britain", "Italy", "Germany"];

for (var place:String in myArray) {
    
    trace(myArray[place]);
    
}

Develop PHP browser display window
France
Great Britain
Italy
Germany

for each ( in ) loop
Using for each ( in ) to iterate over array objectsStart Copy+Paste for this box here on this line of text
Learn HTML
var myArray:Array = ["France", "Great Britain", "Italy", "Germany"];

for each (var place:Object in myArray) {
    
    trace(place);
    
}

Develop PHP browser display window
France
Great Britain
Italy
Germany

while loop
A while loop is a loop that can execute code as long as the expression in parenthesis returns true.
Learn HTML
var myNum:uint = 0;
while (myNum < 4) {
    myNum++;
    trace(myNum);
}

Develop PHP browser display window
1
2
3
4

do while loop

A do while loop is a while loop flipped upside down. It guarentees that the code block inside the loop will execute at least once due to the expression being on the bottom. Code runs from top to bottom.
Learn HTML
var myNum:uint = 1;

do {
    
    trace(myNum);
    myNum++;
    
} while (myNum <= 4);

Develop PHP browser display window
1
2
3
4

                                   That concludes this section, to continue learning Actionscript 3.0 head back to the index


Comment on Looping




Search Tags:
Looping   ·  
 
 
Arbitrary Links and Archives
Home
Active Forums
Members
SIte News
Link To Us
Gear
2009 Forum Archive
Programming Courses
Learn HTML
Learn CSS
Learn PHP
Learn MySQL
Learn Javascript
Learn jQuery
Learn ActionScript 3.0
Learn Java
Learn XML
DevelopPHP Requires Flash Player
Get Adobe Flash player
___________________________________________

Terms of Use  •  Privacy  •  Admin Notes

©2010 developphp.com   |   Powered By FlashBuildingHolder