# How to pause a setInterval

**URL:** <https://forum.kirupa.com/t/how-to-pause-a-setinterval/201185>\
**Category:** Uncategorized\
**Created:** [September 19, 2006, 6:55am UTC](https://forum.kirupa.com/t/how-to-pause-a-setinterval/201185 "2006-09-19T06:55:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chroma](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@chroma](https://forum.kirupa.com/u/chroma)\
**Post date:** [September 19, 2006, 6:55am UTC](https://forum.kirupa.com/t/how-to-pause-a-setinterval/201185/1 "2006-09-19T06:55:33Z")

</div>

Hello everyone. This is my first post on this forum, as been a guest in here for quite a while.  
Okay, let me guide you directly to my problem.

I’m currently programming a strategy game, with timeline (month, year) 15 years duration.  
Im doing a setInterval on this one, which works perfectly well UNTIL I have to make a pause-function. My first thought was to save the currently month and year in variables, clear the setInterval and start the same setInterval again, using if/elses and make the timeline start from where it stopped when the pause is off.

Then the problem comes up. If I was in eg. late june 2000, the game starts again at the start of june 2000. (Which makes an awful bug in the game)

Do I really have to “break down” the timeline into pieces, or is it a better way to pause my setInterval function?

The code is quite a bit, so at first I just want your thoughts about how to pause a setInterval to get it start from exactly the same ms it stopped.  
In my opinion there should really be a predefined setInterval pause-function in flash.

Any help appreciated:ear:
