Here's some interesting details about setInterval. I discovered these things through trial and error, and I figure I should post them here so other people won't waste time trying to use setInterval for things it can't do.
First of all, you don't want to call setInterval in your main loop. If you do, it will wait however many milliseconds, and then perform the action every single frame after that point. The proper way to use setInterval is to run it once at the begining of your program, and then cancel it later.
Is there any way to test and see if an interval is set or not? That would be useful for starting an interval up again in mid-game.
Secondly, there's no point in trying to use setInterval to trigger a function that you want to pass dynamic values to. I am probabaly using the word "dynamic" incorrectly here. By dynamic, I mean values that get their data from an object, such as _root.mymc._width or Math.random()*1000) Values such as these are set in stone when the interval is set.
In my case, I wanted to do this:
setInterval (spawnExplosion, 1000, (Math.random()*_root.screenWidth),(Math.ra
ndom()*_root.screenHeight), 1, 0, "kaboom");
So that explosions would appear all over the screen in random positions. Well, instead, they all appear in exactly the same place, although it is a different place every time the game is run.
So while setInterval may be useful for some things, but it doesn't work the way I thought it did. If you're using it to trigger an existing function, you can only pass values to the function once when the function is run. Now, if I had generated the random numbers within my spawnExplosion function, this would have worked.
I can see now why you didn't bother showing us how to pass values to a function. It isn't all that useful in most situations. You might as well retrieve the values from within the function you're calling.
Guess I'll be incrementing a variable every frame, the old fashioned way. :P
I hope one or two people find this post useful.