Slowing Down While Loop

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?


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