# Perfect setInterval

**URL:** https://forum.kirupa.com/t/perfect-setinterval/187231
**Category:** flash
**Created:** [April 27, 2006, 4:55pm UTC](https://forum.kirupa.com/t/perfect-setinterval/187231 "2006-04-27T16:55:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jasonoda](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@jasonoda](https://forum.kirupa.com/u/jasonoda)
#### Post date: [April 27, 2006, 4:55pm UTC](https://forum.kirupa.com/t/perfect-setinterval/187231/1 "2006-04-27T16:55:03Z")

</div>

I want a piece of code to activate every 1000 milliseconds. However, when I check with getTimer() how many seconds actually pass between activating the function, i get a lot of 1000’s but also a lot of 1009’s and 1050’s. How can I rewrite my function here to get it perfect?

```auto

sitime = new Object();
setInterval(sitime, "interval", 1000);
sitime.interval = function() {
    box2._x+=1
    lasttime = marktime;
    marktime = getTimer();
    timepassed = marktime-lasttime;
    trace(timepassed);
    updateAfterEvent;
};

```
