# \[as2\] help w/ dynamic clearInterval()?

**URL:** <https://forum.kirupa.com/t/as2-help-w-dynamic-clearinterval/290443>\
**Category:** flash\
**Created:** [June 15, 2009, 4:22am UTC](https://forum.kirupa.com/t/as2-help-w-dynamic-clearinterval/290443 "2009-06-15T04:22:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpxnamja](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@kpxnamja](https://forum.kirupa.com/u/kpxnamja)\
**Post date:** [June 15, 2009, 4:22am UTC](https://forum.kirupa.com/t/as2-help-w-dynamic-clearinterval/290443/1 "2009-06-15T04:22:58Z")

</div>

Hello,  
I’ve run into a problem in which I think I must now slit my wrist for…  
I’ve been trying to dynamically clear a triggered setInterval by a parameter, but have had no luck.  
Here’s an example:

```auto

function createShip(to_be_deleted) {
    _root.ecnt++;
    var enemy1:Ship = new Ship(random(400)+40,1,"ship"+_root.ecnt,"ship1",2);
    clearInterval(to_be_deleted);
}
enemy_1 = setInterval(createShip, 1000, enemy_1);

```

This code doesn’t work, but assuming it did, this is what I want it to do:

```auto

function createShip(to_be_deleted) {
     _root.ecnt++;
     var enemy1:Ship = new Ship(random(400)+40,1,"ship"+_root.ecnt,"ship1",2);
     clearInterval(to_be_deleted);
 }
 enemy_1 = setInterval(createShip, 1000, enemy_1);
enemy_2 = setInterval(createShip, 2000, enemy_2);
enemy_3 = setInterval(createShip, 5000, enemy_3);

```

Notice in the faulty code above, I’m using 3 setIntervals, but able to use only one function and one clearInterval. Is this possible?

Thanks for the read.
