# Help With Variable Speed Clock/setInterval

**URL:** <https://forum.kirupa.com/t/help-with-variable-speed-clock-setinterval/233599>\
**Category:** flash\
**Created:** [July 25, 2007, 10:55am UTC](https://forum.kirupa.com/t/help-with-variable-speed-clock-setinterval/233599 "2007-07-25T10:55:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PHYSICS](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@PHYSICS](https://forum.kirupa.com/u/PHYSICS)\
**Post date:** [July 25, 2007, 10:55am UTC](https://forum.kirupa.com/t/help-with-variable-speed-clock-setinterval/233599/1 "2007-07-25T10:55:08Z")

</div>

Hello, everyone. I have had great success in finding help here in the past, so I am hoping that you all can find it in yourselves to assist me once more.

You can see the .swf of what I have created here at [http://web.omnidrive.com/APIServer/public/ZJGPV2IVBnIsEGypToSDo1dt/variclock.swf](http://web.omnidrive.com/APIServer/public/ZJGPV2IVBnIsEGypToSDo1dt/variclock.swf). The idea is that the user can change the speed of the simulation clock at any time using the slider. I noticed while building this, that this thing worked until I tried making it so that the user could change the speed at any time (this is a necessary part of the design). The relevant part of the code is as follows:

> 

var time\_intervalID:Number;  
var stime\_intervalID:Number;  
var time\_interval:Number;  
var stime\_interval:Number;

function clockUpdate() {  
time\_interval = 3600+(1000/60)-\_root.slider\_mc.slider\_value;  
stime\_interval = 1000-\_root.slider\_mc.slider\_value;

if (stime\_interval \< 0) {  
stime\_interval = 0;  
}

clearInterval(time\_intervalID);  
clearInterval(stime\_intervalID);

time\_intervalID = setInterval(\_root.timeUpdate,time\_interval);  
stime\_intervalID = setInterval(\_root.stimeUpdate,stime\_interval);  
runtime\_intervalID = setInterval(\_root.runtimeUpdate,0);  
}

setInterval(clockUpdate,0);

I have also attached the .fla to this post.

I need help with three things. First of all, I need to get the clocks working correctly. Secondly, I would really like it if the user could type in a number and the slider would adjust accordingly (I played with this a lot trying to get it to work, but I never found a solution). Lastly, ANY criticism that you can give me as far as my programming in AS is concerned would be greatly appreciated as I am new to doing much of anything beyond playhead control.

Thanks!
