Perform more complex initializations and increments by adding additional expressions separated by commas : for « Statement « Flash / Flex / ActionScript






Perform more complex initializations and increments by adding additional expressions separated by commas

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        for(var i:Number = 0, a:Number = 25; i < 25; i++, a -= 2) {
          trace(i + " " + a);
        }

    }
  }
}
0 25
1 23
2 21
3 19
4 17
5 15
6 13
7 11
8 9
9 7
10 5
11 3
12 1
13 -1
14 -3
15 -5
16 -7
17 -9
18 -11
19 -13
20 -15
21 -17
22 -19
23 -21
24 -23

        








Related examples in the same category

1.The for Statement
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.