IEventDispatcher null in Model

Kyle's Avatar


03 Jul, 2013 11:01 PM

I know this is a pretty common problem (based on the threads I've read thus far), so I'm hoping there is a really simple answer. I've got a model that has the IEventDispatcher injected into it as such:

public var eventDispatcher:IEventDispatcher;

The problem is that when I try to access eventDispatcher, it is null. I have a config file that is mapping my model:;

...and the config is added to my context:

_context = new Context()
.configure(ModelConfig, ViewConfig, CommandConfig, ServiceConfig, EventConfig, StartupConfig)
.configure(new ContextView(this));

StartupConfig also contains a reference to IEventDispatcher, and is successfully using it (i.e. it is being injected correctly). I'm sure there is something ridiculously simple I'm missing here..?

Showing page 2 out of 2. View the first page

  1. Support Staff 30 Posted by Ondina D.F. on 11 Jul, 2013 12:13 PM

    Ondina D.F.'s Avatar

    just store the context instance in a property, BEFORE starting the method chaining:

    Yes, that’s already been discussed in the previous posts. []

    it doesn't have anything to do with the context view already being on the stage.

    Ok, then we don’t need the StageSyncExtension at all.
    We could do just this:

    public function MinimalistContext(view:DisplayObjectContainer)
         _context = new Context()
         .configure(new ContextView(view))

    Probably we should point this out somewhere in the documentation.

    Oh yes, we should!!!

  2. Support Staff 31 Posted by Shaun Smith on 11 Jul, 2013 12:31 PM

    Shaun Smith's Avatar

    The StageSyncExtension is indeed the culprit here. I've been considering making it wait a frame for ages, I'm just a little concerned with subtle side-effects

  3. Ondina D.F. closed this discussion on 30 Aug, 2013 07:55 AM.

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