Flashadvisor logo
:: Desktop Shortcut
:: Flash Help
Advices from Experts

 Submit Here! · Link to Us · Newsletter · Tell a Friend ·

      Add Tutorial |

 

Advertise here










 

Google

Search WWW   
FlashAdvisor.com

 Home > Tutorials  > ActionScript

Flash Actionscript Programming Basics

Author: steve happ | Email
Website : www.video-animation.com


Advertisement

LOOPS



A loop cycles over a body of code as long as the condition remains true.




while



template:


while(expression){
statement;
}

The statement is executed as long as the conditions is true. E.g.

var x =0;
while(x < 10){
trace(x);
x++;
}



do .. while



a do.. while loop executes the statement once before the condition is evaluated.
Template:


do{
//Statements to be executed;
}
while(condition);


E.g.

var x =0;
do{
trace(x);
x++;
}
while (x < 10);




for



a for loop is used most commonly to step through a fixed length data structure such as an array.
Template:


for(init-statement; expr2;expr3){
// Statements;
}

e.g.

for(var i=0; i<10; i++){
trace(i);
}

the first statement initialises a looping variable
3. sets the condition
3. increments the looping variable( also could be something like i=i+2)




| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 |

Rate This Tutorial :
We hope the information helped you. If you have any questions or comments, please don't hesitate to post them on the Forums section
Submit your Tutorial at Click Here
  

Home | About Us | Contact Us | Feedback | Advertise with us

Best viewed in 800x600 resolution with Internet Explorer.

Site Developed and Hosted by  ethicsolutions.com
All rights reserved with FlashAdvisor

Flash is a registered trademark of Adobe Systems, Inc.

28 users online