DelayCall

DelayCall provides a mechanism to have function calls executed after the current event has finished.  It is usable for example when a long running task needs to provide progress feedback or to avoid the Flash Player timeout.

An alternative to the internal timer implementation would be to use enter frame events.

Summary
DelayCallDelayCall provides a mechanism to have function calls executed after the current event has finished.
Private members
delayedCallTimer object used to trigger the delayed function call.
callbackFunctionHolds a reference to the function to call
callbackContextHolds a reference to an object used as an argument to the delayed function.
Public methods
DelayCallConstructs a delayed function call that is triggered after the code executing in current event has finished.
destructorCleans up resources used by the delayed call.
callAgainCall this method from within a delayed function to simulate a recursive loop.
Private methods
callbackHandlerCalls the delayed function with its context argument.

Private members

delayedCall

private var delayedCall: Timer

Timer object used to trigger the delayed function call.

callbackFunction

private var callbackFunction: Function

Holds a reference to the function to call

callbackContext

private var callbackContext: Object

Holds a reference to an object used as an argument to the delayed function.

Public methods

DelayCall

public function DelayCall(procedure: Function,
context: Object)

Constructs a delayed function call that is triggered after the code executing in current event has finished.  The context object can be of type object so a number of properties can be passed to the function.

Parameters

procedureThe function to call later.
contextA parameter for the function.

Callbacks

procedurefunction onDelayCall(context:Object):void

destructor

public function destructor():void

Cleans up resources used by the delayed call.  This method should be called from within the delayed function.

callAgain

public function callAgain():void

Call this method from within a delayed function to simulate a recursive loop.  Correct usage requires that the context object contains a stop condition variable to prevent a never ending loop.

Private methods

callbackHandler

private function callbackHandler(event: TimerEvent):void

Calls the delayed function with its context argument.  Shields the function from the internal timer implementation and calls updateAfterEvent to trigger an update of the display after the function has completed.

private var delayedCall: Timer
Timer object used to trigger the delayed function call.
private var callbackFunction: Function
Holds a reference to the function to call
private var callbackContext: Object
Holds a reference to an object used as an argument to the delayed function.
public function DelayCall(procedure: Function,
context: Object)
Constructs a delayed function call that is triggered after the code executing in current event has finished.
public function destructor():void
Cleans up resources used by the delayed call.
public function callAgain():void
Call this method from within a delayed function to simulate a recursive loop.
private function callbackHandler(event: TimerEvent):void
Calls the delayed function with its context argument.
Close