# Slowing Down While Loop

**URL:** <https://forum.kirupa.com/t/slowing-down-while-loop/294849>\
**Category:** flash\
**Created:** [August 20, 2009, 9:02pm UTC](https://forum.kirupa.com/t/slowing-down-while-loop/294849 "2009-08-20T21:02:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thesprucegoose](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@thesprucegoose](https://forum.kirupa.com/u/thesprucegoose)\
**Post date:** [August 20, 2009, 9:02pm UTC](https://forum.kirupa.com/t/slowing-down-while-loop/294849/1 "2009-08-20T21:02:13Z")

</div>

Hey All,

I’m currently creating a rewind function that makes a video go to a certain frame number when a button is clicked. The issue is that the code is shooting through the frames too quickly. Is there any way to slow this down?

```auto

stop ();

slider.minimum = 1;
slider.maximum = target.totalFrames;
slider.liveDragging = true;

slider.addEventListener ( Event.CHANGE, sliderChangeHandler );

rewindButton.addEventListener ( MouseEvent.CLICK, rewindMovie );

trace(target.totalFrames);

function rewindMovie (e: Event ) : void {
        trace("Function started");
        while (slider.value != 676) {
            if (slider.value > 676 ) {
                slider.value = slider.value - 1;
                target.gotoAndStop ( slider.value );
            } else {
                slider.value = slider.value + 1;
                target.gotoAndStop ( slider.value );
                
            }//END IF
                
            
        }// END WHILE
    
    
    }//END FUnCTION
    

function sliderChangeHandler ( e : Event ) : void
{
    target.gotoAndStop ( slider.value );
    trace(slider.value);
}

```

Thanks,

–thesprucegoose
