The for Statement : for « Statement « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » Statement » for 




The for Statement
 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


        var total = 2;
        
        for (var i = 0; i < 2; i++) {
          total = total * 2;
        }
        
        //here's the equivalent while loop:
        var total = 2;
        var i = 0;
        
        while (i < 2) {
          total = total * 2;
          i++;
        }
    }
  }
}

        














Related examples in the same category
1.Perform more complex initializations and increments by adding additional expressions separated by commas
2.Use a for loop to check whether a string contains the @ character
3.Place two statements in the for statement
4.Nested for loops
5.Use for each loop to go through the array elements
6.Use for loop to loop through the dynamic array
7.Use for statements to loop backward:
8.Use for loop statement to display all elements in an array
9.Use For in loop to display all properties in an object
10.break is a keyword that allows you to stop processing a loop or conditional.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.