# setTimeout / clearTimeout problem

**URL:** <https://forum.kirupa.com/t/settimeout-cleartimeout-problem/293585>\
**Category:** flash\
**Created:** [July 31, 2009, 1:53am UTC](https://forum.kirupa.com/t/settimeout-cleartimeout-problem/293585 "2009-07-31T01:53:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_hansen84](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@mr\_hansen84](https://forum.kirupa.com/u/mr_hansen84)\
**Post date:** [July 31, 2009, 1:53am UTC](https://forum.kirupa.com/t/settimeout-cleartimeout-problem/293585/1 "2009-07-31T01:53:47Z")

</div>

Hey Lads,

Im doing a banner rotation thing and im using tweens and setTimeout to rotate through the images. I want to add a back and a forward button so the user can flick through the images as he pleases. It all works fine apart from when the “setTimeout mode” is active and the back button is pressed… this is the active code when the back button is pressed:

function back\_btn\_func(evt:MouseEvent)  
{  
clearTimeout(this.Timeout2);  
firstTween.stop();  
firstTween.rewind();  
secondTween.stop();  
secondTween.rewind();  
imgCounter–  
secondLoad();  
}

// and this is the setTimeout

var Timeout2:Number = setTimeout(firstLoad, 2000);

so when i press the back button whilst inbetween the 2000ms, it loads “firstLoad” AND “secondLoad”… and ofc it should only load secondLoad. Surely clearInterval(Timeout2) should stop the laoding of “firstLoad” ? am i missing something? or is there a smoother way of doing the same trick ?

thanks in advance!
