Name
LzDelegate — The receiver in Laszlo's point-to-point event system.
Description
A delegate is an object that calls a specific method in a specific context
when its execute method is called. It is essentially a function pointer.
Delegates, along with LzEvent, comprise Laszlo's point to point event system. A delegate represents a named method of an instance. Delegates are mostly
registered with events, but they can be used anywhere a function callback would traditionally be called for: for instance,
the LzTimer service takes a delegate as its argument when a timer is started. See the code example on the LzEvent.
Superclass Chain
LzDelegate
Details
Properties (5)
-
c
-
The context in which to call the method
-
enabled
-
public var enabled = true;
-
event_called
-
public var event_called = false;
-
f
-
The name of the method to call
-
lastevent
-
public var lastevent = 0.0;
Methods (7)
-
disable()
-
public function disable();
Disables the delegate until enable method is called.
-
enable()
-
public function enable();
Enables a delegate that has been disabled
-
execute()
-
protected function execute(sd);
Executes the named method in the given context with the given data. Returns
the result of the call. In rare cases, this method may be overriden by a
subclass, and so it is marked 'protected' instead of 'private'.
-
initialize()
-
public function initialize(context : Object, functionName : String, eventSender : Object, eventName : String);
-
register()
-
public function register(eventSender : Object, eventName : String);
Registers the delegate for the named event in the given context.
NB:
This is the primary way in which events are created. Published events do
not generally exist as objects (with some exceptions) until delegates are
created for them.
-
unregisterAll()
-
public function unregisterAll();
Unregisters the delegate for all of the events it is registered for.
-
unregisterFrom()
-
public function unregisterFrom(event : LzEvent);
Unregisters the delegate for the given event
JavaScript Synopsis
public
LzDelegate {
prototype public function
disable
();
prototype public function
enable
();
prototype protected function
execute
(
sd);
prototype public function
initialize
(
context : Object,
functionName : String,
eventSender : Object,
eventName : String);
prototype public function
register
(
eventSender : Object,
eventName : String);
}