callLater is used to defer the function call to "as soon as possible".  That's 
why it hooks both enterFrame and render.

Timers are used to wait, especially when we know we don't need to run that 
function "right away".

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: [email protected] [mailto:[email protected]] On Behalf 
Of Aaron Hardy
Sent: Thursday, October 29, 2009 7:47 PM
To: flexcoders
Subject: [flexcoders] Delaying a function's execution



Hey flexers,

I've been researching the various ways that one can delay a function's 
execution.  A few ways I've found/used are:

(1) Use a Timer object with 0 delay as is done in 
StyleManagerImpl.loadStyleDeclarations2().
(2) Use setTimeout() (supposedly deprecated?)
(3) Use callLater if you're in a UIComponent. (does it actually wait a frame or 
just till rendering beings?)
(4) If you're not in a UIComponent, use the same logic that's found in 
UIComponent's callLater.  It appears to add an event listener to the stage 
(using SystemManager to access the stage) for Event.RENDER and 
Event.ENTER_FRAME then invalidates the stage.

First, is callLater meant to wait until the next frame or just until the render 
segment of the elastic racetrack?
Second, which would you recommend and why?
Third, why does the Flex framework use varying methods of waiting a frame (see 
#1 and #4)?  The answer to my first question might answer this one.
Fourth, why does callLater watch for both Event.RENDER and Event.ENTER_FRAME 
event types and not just one or the other?

Thanks for answering my questions.  I appreciate it.

Aaron

Reply via email to