# For loop, count by 2's instead of i++?

**URL:** <https://forum.kirupa.com/t/for-loop-count-by-2s-instead-of-i/251086>\
**Category:** Uncategorized\
**Created:** [February 5, 2008, 8:33am UTC](https://forum.kirupa.com/t/for-loop-count-by-2s-instead-of-i/251086 "2008-02-05T08:33:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyler\_j](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@tyler\_j](https://forum.kirupa.com/u/tyler_j)\
**Post date:** [February 5, 2008, 8:33am UTC](https://forum.kirupa.com/t/for-loop-count-by-2s-instead-of-i/251086/1 "2008-02-05T08:33:02Z")

</div>

Hi there,

I am wondering what the trick is to count by two’s. So I have a loop, currently going from 0 to 400 (my stage height), but instead of looping 1,2,3,4,5,6… i want it to just do every second one 1,3,5,7,9…

any ideas? thanks in advance

heres a portion of my code:

```auto

public function populate():void {
     for (var i = 0; i < h; i++) {
          var theY:int = i;

          line.graphics.lineStyle(1, Math.random()*0xFFFFFF, Math.random());
          line.graphics.moveTo(0, theY);
          line.graphics.lineTo(w, theY);

          addChild(line);
     }
}

```
