The single best method I have seen for managing intervals is to store the intervalId in a new object, then pass a reference of that object to the interval handler as an argument.

With this, you don't clutter up your classes with interval management member variables, the called method can execute code in the scope of where it is declared. and then simply clear the interval whenever it wants to...

    public function beginInterval():Void {
        var obj:Object = new Object();
        obj.id = setInterval(this, "doSomething", 200, obj);
    }
    
    public function doSomething(obj:Object):Void {
        trace("doSomething called with: " + obj.id);
        this.doSomethingElse();
        clearInterval(obj.id);
    }

    public function doSomethingElse():Void {
        trace("doSomethingElse called");
    }


I haven't tested the code - but it should work...


Good Luck,

Luke Bayes
www.asunit.com
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to