Interface adways.event.IEventDispatcherR

IEventDispatcherR interface description

<Number> addEventListener( kind, callback, [instance=null], [priority=0], [useWeakReference=false] ) public

Adds an event listener of a specific event kind.

Parameters:

  • kind <Constant>

    kind of the event to listen

  • callback <FUNCTION>

    function called when the event is fired

  • [instance=null] <Object> optional

    callback's instance. Useful when the callback is binded to an object:

                        Class = function () {};
                        Class.prototype.callback = function () {};
                        var a = new Class();
                        aDispatcher.addEventListener(AN_EVENT_KIND, a.callback, a);

  • [priority=0] <Number> optional

    priority

  • [useWeakReference=false] <Boolean> optional

    not yet used

Return: <Number>:

1 if event added, 0 otherwise (already added callback).

When instance==null, the callback should be accessible from the global context and be a "static" method. Exemple:

                    namespaceA.subnamespace.myCallback = function (event) {
                    ...
                    };
                    aDispatcher.addEventListener(AN_EVENT_KIND, namespaceA.subnamespace.myCallback);

<Number> hasEventListener( kind, callback, [instance=null] ) public

Whether or not a listener has already been added.

Parameters:

  • kind <Constant>

    the event's kind

  • callback <FUNCTION>

    the listener's function

  • [instance=null] <Object> optional

    the listener callback's instance

Return: <Number>:

the listeners count.

<Number> nbEventListeners( kind ) public

Counts the listeners added for a specific event.

Parameters:

  • kind <Constant>

    the event's kind

Return: <Number>:

the listeners count.

<Number> removeAllEventListeners( ) public

Removes all the listeners.

Return: <Number>:

1 on success (currently always), 0 otherwise.

<Number> removeEventListener( kind, callback, [instance=null] ) public

Removes an event listener of a specific event kind.

Parameters:

  • kind <Constant>

    kind of the event to listen

  • callback <FUNCTION>

    function called when the event is fired

  • [instance=null] <Object> optional

    callback's instance

Return: <Number>:

1 if event removed, 0 otherwise ( couple &lt instance + callback &gt not found).