Delegate

Kind of class:public class
Package:com.bourre.commands
Inherits from:none
Implements:
Author:Francis Bourre
Classpath:com.bourre.commands.Delegate
File last modified:Monday, 24 November 2008, 11:36:52
The Delegate encapsulate a method call as an object.
The Delegate class provides two ways to encapsulate a method call :
  • By creating a new Delegate instance you can wrap the call into
    a command object.
  • By calling the Delegate.create method you can get
    an anonymous function which will encapsulate the call.

Summary


Constructor
  • Delegate (f:Function, rest)
    • Creates a new Delegate instance which encapsulate the call
Class methods
  • create (method:Function, args) : Function
    • Creates a anonymous function which will wrap the call
Instance methods
  • bypassEventCallback (b:Boolean) : void
    • If true the event passed to the execute
  • getArguments : Array
    • Returns the current array of arguments which will be
  • setArguments (rest) : void
    • Defines the arguments to pass to the function
  • setArgumentsArray (a:Array) : void
    • Defines the arguments to pass to the function
  • addArguments (rest) : void
    • Appends arguments to the current function's arguments.
  • addArgumentsArray (a:Array) : void
    • Appends arguments to the current function's arguments.
  • execute (event:Event = null) : void
    • Realizes the function call with the arguments defined
  • handleEvent (e:Event) : void
    • Allow the delegate object to be added as listener
  • callFunction : *
    • Calls the function with the current array of arguments.
  • toString : String
    • Returns the string representation of this instance.
Event handlers
  • onTick (e:Event = null) : void

Constructor

Delegate

public function Delegate (
f:Function, rest)

Creates a new Delegate instance which encapsulate the call
to the passed-in function with the passed-in restas arguments to the function.
Parameters:
f :
specified method to encapsulate
rest:
additionall arguments to pass to pass
to the method

Class methods

create

public static function create (
method:Function, args) : Function

Creates a anonymous function which will wrap the call
to the passed-in function with the passed-in restas arguments to the function.
Parameters:
method:
specified method to encapsulate
args :
additionall arguments to pass to pass
to the method
Returns:
  • an anonymous function which will wrap the call
    to the passed-in function

Instance methods

addArguments

public function addArguments (
rest) : void

Appends arguments to the current function's arguments.
Parameters:
rest:
arguments to append to the function's
arguments

addArgumentsArray

public function addArgumentsArray (
a:Array) : void

Appends arguments to the current function's arguments.
Parameters:
a:
array of arguments to append to the function's
arguments

bypassEventCallback

public function bypassEventCallback (
b:Boolean) : void

If true the event passed to the execute
function will not be appended to the function arguments.
Parameters:
b:
true to bypass the event to be
appended to the function arguments

callFunction

public function callFunction (
) : *

Calls the function with the current array of arguments.

execute

public function execute (
event:Event = null) : void

Realizes the function call with the arguments defined
in this Delegate object.

The receive event will be append to the arguments array
except if the bypassEvenCallback have been
called with true as argument.

Parameters:
event:
event object to append to the arguments
array

getArguments

public function getArguments (
) : Array

Returns the current array of arguments which will be
passed to the function when called.
Returns:
  • array of arguments which will be
    passed to the function

handleEvent

public function handleEvent (
e:Event) : void

Allow the delegate object to be added as listener
for any event type on any object which provide the

addEventListener.
Parameters:
e:
event object dispatched with the event

setArguments

public function setArguments (
rest) : void

Defines the arguments to pass to the function
Parameters:
rest:
arguments to pass to the function

setArgumentsArray

public function setArgumentsArray (
a:Array) : void

Defines the arguments to pass to the function
Parameters:
a:
array of arguments to pass to the function

toString

public function toString (
) : String

Returns the string representation of this instance.
Returns:
  • the string representation of this instance

Event handlers

onTick

public function onTick (
e:Event = null) : void

Parameters:
e:
event dispatched by the beacon object
#
Specified by: