# FLASH 8 HELP: setInterval with bullets

**URL:** <https://forum.kirupa.com/t/flash-8-help-setinterval-with-bullets/226512>\
**Category:** programming\
**Created:** [May 22, 2007, 12:13am UTC](https://forum.kirupa.com/t/flash-8-help-setinterval-with-bullets/226512 "2007-05-22T00:13:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Holmesc](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@Holmesc](https://forum.kirupa.com/u/Holmesc)\
**Post date:** [May 22, 2007, 12:13am UTC](https://forum.kirupa.com/t/flash-8-help-setinterval-with-bullets/226512/1 "2007-05-22T00:13:27Z")

</div>

I’m making a side-scrolling platformer game. I’ve made it so that the character runs, jumps, and shoots fireballs. However, I need to set up a way to prevent the player from holding down the fire button and letting out a steady stream of fireballs. I know that I could do this using setInterval, but (despite reading tutorials) I can’t figure out exactly how it works/how to implement it. Here’s the piece of my script where I want the firing code to go:

```auto
var number:Number = 1;
hero.onEnterFrame = function() {
    if (Key.isDown(Key.SPACE)) {
        fireball();
    }
};
fireball = function () {
    attachMovie("fireball", "fireball"+number, number);
    _root["fireball"+number]._x = hero._x+10;
    _root["fireball"+number]._y = hero._y-25;
    _root["fireball"+number]._xscale = hero._xscale;
    number += 1;
    if (number == 50) {
        number = 1;
    }
};

```

Obviously, I cut out the rest of the code for the hero’s running, jumping, etc. because it’s not necessary. If you need to see it though, just post. Thanks for any and all help, it’s much appreciated!
