redispatch - command - event properties

duncan.reid's Avatar

duncan.reid

08 Nov, 2010 06:41 PM

Hi Guys,

I have a command mapped to a navigation event, NavigationEvent is overriding clone:
commandMap.mapEvent( NavigationEvent.ON_ITEM_SELECT, NavigationCommand, NavigationEvent );

In my navigation item view i dispatch this navigation event to it's mediator, passing a vo:
var e:NavigationEvent = new NavigationEvent( NavigationEvent.ON_ITEM_SELECT);
e.vo = vo;
dispatchEvent( e );

the mediator grabs this and sends the event to the command via addViewListener:
addViewListener( NavigationEvent.ON_ITEM_SELECT, dispatch, NavigationEvent );

the command fires but I am unable to retrieve the value object in NavigationCommand, the value object is null:
[Inject] public var event:NavigationEvent;

override public function execute():void
{

trace( this + "vo : " + event.vo );

}

if I repackage the event in my mediator it will work fine, the command is called and the event property is passed:

addViewListener( NavigationEvent.ON_ITEM_SELECT, doRepackage, NavigationEvent );

private function doRepackage( e:NavigationEvent ):void {

var event:NavigationEvent = new NavigationEvent( NavigationEvent.ON_ITEM_SELECT );
event.vo = e.vo;
dispatch( event );

}

I'm just wondering if maybe I'm overlooking something?

using 1.4.0.

Thanks,
Dunc

  1. 1 Posted by Jason Dias on 08 Nov, 2010 06:54 PM

    Jason Dias's Avatar

    Can you post your clone method?

    It sounds like you're not reassigning the vo in the clone method.

  2. 2 Posted by duncan.reid on 08 Nov, 2010 07:00 PM

    duncan.reid's Avatar

    Hi Jason,

    Thanks for the quick response. This is what my NavigationEvent looks like where I am overriding clone, is this what you are asking for?

    public class NavigationEvent extends Event
    {
    
        public static const ON_ITEM_SELECT:String = "ON_ITEM_SELECT";
        public var vo:NavigationVO;
    
        public function NavigationEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
        {
            super(type, bubbles, cancelable);
        }
    
        override public function clone():Event {
            return new NavigationEvent( type );
        }
    }

    override public function clone():Event {

    return new NavigationEvent( type );

    } }

    Thanks again,
    Dunc

  3. 3 Posted by Jason Dias on 08 Nov, 2010 07:08 PM

    Jason Dias's Avatar

    Yea, you need to reassign the vo in the clone,

    `override public function clone():Event {

    var e:NavigationEvent = new NavigationEvent( type );
    e.vo = vo;
    return e;

    }`

  4. 4 Posted by duncan.reid on 08 Nov, 2010 07:51 PM

    duncan.reid's Avatar

    Ok, I see. Thanks much for your help Jason!

  5. Stray closed this discussion on 10 Feb, 2011 06:07 PM.

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

Keyboard shortcuts

Generic

? 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