The most sensible way to use Intervals, which are very useful - but
dangerous when not managed correctly, is to use an implementation of
TimeOut, so you fire object methods after a given delay and the API you
use for this, automatically clears up the interval. I can speak from
experience as to the annoyance of debugging code where setInterval /
clearInterval has been used irresponsibly.

Eg:


class TimeOut
{
        
        public static function create(interval : Number, scope : Object,
method : Function, parameters : Array) : Void {
                var intervalID : Number;
                var timeoutFunction : Function = function() : Void {
                        clearInterval(intervalID);
method.apply(scope, parameters);                        
                };
                intervalID = setInterval(timeoutFunction, interval,
parameters);    
                                        
        }
}


Usage:

import TimeOut;

function someFunction(arg:String) : Void{
        trace(arg);
}

TimeOut.create(5000,this,someFunction,["I should be called after 5
seconds"]);


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven
Sacks
Sent: 25 April 2007 17:26
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Clear Set Interval Q:

Danny,

I think you're missing out by not using Intervals.  They're extremely 
useful (and efficient) once you get familiar with them.

If you're looking for one that you don't have to keep track of, google 
"Kenny Bunch Interval Manager".  It takes care of a lot of interval 
overhead and puts all intervals in one location (namespace).

To Muzak's point, I'm able to have multiple instances of the same class 
each have their own interval running inside them.  Do you mean if you 
make the interval var static?

-Steven
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to