# Function timer

**URL:** <https://forum.kirupa.com/t/function-timer/313510>\
**Category:** programming\
**Created:** [September 1, 2010, 1:58pm UTC](https://forum.kirupa.com/t/function-timer/313510 "2010-09-01T13:58:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skribble](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Skribble](https://forum.kirupa.com/u/Skribble)\
**Post date:** [September 1, 2010, 1:58pm UTC](https://forum.kirupa.com/t/function-timer/313510/1 "2010-09-01T13:58:55Z")

</div>

Hey guys, just a quick question for a little shmup I’m working on.

I’ve set up a function so that I can spawn an enemy movieclip with a bunch of defined properties, like this:

//Enemy type, Spawn type, Spawn amount, Spawn delay  
spawnEnemy(enemiesArray[drone], “singleWave”, 6, 30);

So it spawns my enemy, gives it a formation type, says how many enemies should spawn, and the gives the delay between each spawned enemy. The only thing is I can’t figure out how to set up the delay.

How can I set up a function that will run a certain amount of times every X frames/milliseconds? I know I can just set up a timer variable in an onEnterFrame but I’d rather not do it that way if possible.

Any help is greatly appreciated.

Thanks!

Brendan
