Event dispatched from a command is not received.

Jim's Avatar

Jim

29 Sep, 2011 04:33 PM

I have a command that is set up like this in the startup of the Context:

commandMap.mapEvent(MainEvent.INIT_APP, AppInitCommand, MainEvent, true);
var initEvent:MainEvent = new MainEvent(MainEvent.INIT_APP);
dispatchEvent(initEvent);

The command executes fine. Then in the command I have this:

loginEvent = new LoginEvent(LoginEvent.ACTIVATE_ACCOUNT);
loginEvent.sessionId = o.sessionId;
eventDispatcher.dispatchEvent(loginEvent);

In a mediator I have this:
eventMap.mapListener(eventDispatcher, LoginEvent.ACTIVATE_ACCOUNT, activateAccount);

But the mediator never seems to be receiving the event. Obviously I need to change what I am doing somewhere. Is it that only the context can receive the event? Should my app init code be in the mediator instead? I definitely overrode the clone in the Event. Thanks for any help.

  1. 1 Posted by neil on 29 Sep, 2011 05:10 PM

    neil's Avatar

    check that the onRegister method of the mediator is fired
    if its not the mediator has not been created yet...
    so check that the view has been attached.

    this is most prob a timing issue

    must go... wife calling me to supper table, and I'm gonna get it

  2. 2 Posted by krasimir on 29 Sep, 2011 05:15 PM

    krasimir's Avatar

    @nail is right I think. Probably your view is not added on the stage when you call dispatchEvent(initEvent); I.e. the onRegister method of the mediator is not called and the listener for LoginEvent.ACTIVATE_ACCOUNT is not added.

  3. 3 Posted by Jim on 29 Sep, 2011 06:08 PM

    Jim's Avatar

    Thanks guys, that was the case. Now I dispatch the event in the onRegister of the Mediator and it works.

  4. Ondina D.F. closed this discussion on 01 Nov, 2011 11:53 AM.

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