# as2 oop - can't get setInterval to work

**URL:** <https://forum.kirupa.com/t/as2-oop-cant-get-setinterval-to-work/225306>\
**Category:** flash\
**Created:** [May 10, 2007, 3:45pm UTC](https://forum.kirupa.com/t/as2-oop-cant-get-setinterval-to-work/225306 "2007-05-10T15:45:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jansensan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jansensan/32/3362_2.png) [@jansensan](https://forum.kirupa.com/u/jansensan)\
**Post date:** [May 10, 2007, 3:45pm UTC](https://forum.kirupa.com/t/as2-oop-cant-get-setinterval-to-work/225306/1 "2007-05-10T15:45:59Z")

</div>

hello all, i am stuck here

i am trying to trigger a function after a certain delay, which is why i used setInterval.

i can get the function to happen after a certain time, but clearInterval doesnt seem to work

it always worked before, when i was not writing it in oop, is there something special with this function when it’s used in oop?

in the Delay.as file:

```auto

class Delay extends MovieClip {
    //
    ///////////////
    // variables //
    ///////////////
    //
    var delay:Number;
    private var countdown:Number;
    //
    /////////////////
    // constructor //
    /////////////////
    //
    function Delay () {
    }
    //
    ///////////////////////////
    // functions definitions //
    ///////////////////////////
    //
    function init (x:Number, y:Number) {
        this._x = x;
        this._y = y;
    }
    function onRelease () {
        traceStuff ();
    }
    //
    function traceStuff () {
        this.countdown = setInterval (delayedtraceStuff, 2500);
    }
    function delayedtraceStuff () {
        this.delay--;
        if (delay <= 0) {
            trace ("stuff");
            clearInterval (this.countdown);
        }
    }
    //
}

```

on test\_delay.fla stage:

```auto

this.attachMovie ("square_inLib", "square", this.getNextHighestDepth ()).init (64, 64);

```

quite appreciated if someone could explain what im doing wrong

see attached files if need be.
