Robotlegs - second dispatch does not work with addViewListener

tangent's Avatar


23 Dec, 2012 10:54 AM

I have a mediator created in Robotlegs, and its related view would dispatch two different kinds of events. When the mediator captures the event, it would just simply dispatch the event. The problem I ran into was that the first event is re-dispatched flawlessly, but the 2nd event was not dispatched.

However, if I manually assign a different handler to the 2nd event, the event is properly captured.

Below is the relevant code:

public class MyMediator extends Mediator
    public var view:MyView;

    public override function onRegister():void

        addViewListener( SomeEventTypeA.COOL_EVENT, dispatch, SomeEventTypeA ); // This event is dispatched correctly
        addViewListener( SomeEventTypeB.STUCK, dispatch, SomeEventTypeB );  // This one is not correctly dispatched

        //A twist, if I uncomment the following code, the event is captured by its handler
        //addViewListener( SomeEventTypeB.STUCK, view_stuck, SomeEventTypeB );

    private function view_stuck( event:SomeEventTypeB ):void
        //ah ha, this is called correctly if the above relevant line is uncommented
  1. Support Staff 1 Posted by Ondina D.F. on 23 Dec, 2012 12:24 PM

    Ondina D.F.'s Avatar

    Hey tangent,

    Since it works within the view_stuck() handler, it’s most likely you forgot to override clone() in your SomeEventTypeB.

    On a side note, you don’t need to call super.onRegister(); if you have this:

    override public function onRegister():void


    Let me know whether overriding clone() solved your issue or not.

  2. 2 Posted by tangent on 23 Dec, 2012 01:24 PM

    tangent's Avatar

    Ondina, you are quite correct, I didn't have proper clone method for the particular event. After adding proper clone method, it works as expected!

  3. Support Staff 3 Posted by Ondina D.F. on 24 Dec, 2012 03:42 PM

    Ondina D.F.'s Avatar

    Hi tangent,

    I’m glad you are back on track.


  4. Ondina D.F. closed this discussion on 24 Dec, 2012 03:42 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac