# For loop timer help

**URL:** <https://forum.kirupa.com/t/for-loop-timer-help/299706>\
**Category:** Uncategorized\
**Created:** [November 9, 2009, 9:22pm UTC](https://forum.kirupa.com/t/for-loop-timer-help/299706 "2009-11-09T21:22:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navarone](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@Navarone](https://forum.kirupa.com/u/Navarone)\
**Post date:** [November 9, 2009, 9:22pm UTC](https://forum.kirupa.com/t/for-loop-timer-help/299706/1 "2009-11-09T21:22:19Z")

</div>

I need some help understanding for loop and timers and what I want to do is set the timer so it counts. Every 3 seconds add 1 to the count and then call a function. If the count reaches 3 then reset every thing and start over. But it isn’t working the way I want it too.

```auto

//create timer for slide show
        var delay:uint = 3000;
        var myTimer:Timer = new Timer(delay);
        myTimer.addEventListener(TimerEvent.TIMER, loopImages, false, 0, true);
        myTimer.start();

        function loopImages(event:TimerEvent):void {
            for (var i:Number = 0; i < 4; i++) {
                trace(i);
                if (i==0) {
                    loadPhoto0();
                } else if (i==1) {
                    loadPhoto1();
                } else if (i==2) {
                    loadPhoto2();
                } else if (i==3) {
                    loadPhoto3();
                } else if (i==4) {
                    i==0;
                }
            }
        }

```
