As a posted last week or something, there's a few things to keep in mind when 
using setInterval

- clear interval before setting it
- always use this syntax setInterval(scope, "method", interval)
- and never use this syntax setInterval(function, interval)
- keep a reference to the interval
- remove it when done

If things go haywire, you're doing something wrong and you probably forgot one 
of the above.

If you're referring to everything using _root, code in the main timeline and 
advise others to do so, please join the flashnewbie 
list
http://chattyfig.figleaf.com/mailman/listinfo/flashnewbie

regards,
Muzak


----- Original Message ----- 
From: "Kalani Bright" <[EMAIL PROTECTED]>
To: <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, March 01, 2007 3:15 AM
Subject: RE: [Flashcoders] Getting frustrated. regarding set Interval,and for 
loop.


> When I was using AS2 I found that no matter what there were always memory
> leaks with set interval and even after I explicitly tell Flash to remove the
> interval it never got removed...
>
> So even though I never wrote it I would offer the following advice, which is
> to *almost* not use setInterval at all.  Just use it once, for the root...
> 1) Move all functionality for intervals to a script on the root
> 2) The root is always available, and you won't have intervals all over the
> place
> 3) Create only one interval for a function on the root which is responsible
> for calling functions
> 4) The function should get the same sort of information as whats required by
> setInterval.
> 5) Call functions based on the timer.  Time since movie started.  A little
> math should test if the objects which are registered with your script should
> be called again.  I would also recommend enabling this function to support
> something like  "call this function X times every 1000 ms).  Rather than
> call this object every 1000ms.  That way you can delete it automatically if
> its reached that number.
> 6) That script keeps information on what intervals are set
> 7) The script periodically checks for objects which no longer exists and
> deletes them from the interval array.
> 8) Intervals are set or removed by calling a root function.  Use the
> delegate class to say which function gets the interval callback and also
> pass a reference to the object.
>
> Good luck,
>
> Kalani
>
>


_______________________________________________
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