Is it possible to map events directly from contextView's stage without contetxView Mediator?

kaspar's Avatar

kaspar

09 Dec, 2011 10:28 AM

Hey everyone,

My question is that - is it possible to map events from contextView's(root) stage object without contextView Mediator?
This is for communication with the flash that loads my robotlegs flash app.
The flash that loads my app calls loader.content.dispatchEvent...

  1. 1 Posted by Stray on 09 Dec, 2011 10:38 AM

    Stray's Avatar

    Hi there,

    There are 2 easy ways to achieve this:

    1. You can still use a mediator - just create it manually (check out the API of mediator and you'll see how that's done). I'm not sure why you specifically asked to do it without a contextView Mediator... so that may not fit.

    2. you can use a plain Actor (which has an instance of the sharedEvent dispatcher) as a kind of lightweight mediator, to listen for the events directly and then redispatch it on the shared eventDispatcher so that commands etc can respond. Actor has an eventMap so just create a singleton of that, inject or pass in the stage object and then do your wiring.

    hth,

    Stray

  2. 2 Posted by kaspar on 09 Dec, 2011 12:34 PM

    kaspar's Avatar

    Thank you for your answer!

    I started with an actor but in the end it looked essentially like a command so I was hoping that it would be possible to use just a command.

    But how can I make the contextView's stage object available for injection?

    Another question - if I use the contextView mediator and my swf is unloaded or deleted from the main swf that loaded it - will it trigger the onRemove on contextView mediator?

  3. 3 Posted by Stray on 09 Dec, 2011 02:44 PM

    Stray's Avatar

    No problem,

    I would just inject contextView itself and then get the stage object from there.

    And yes - if your swf is unloaded then onRemove in the mediator for the contextView should be triggered as the contextView will no longer be on the stage - unless you shut down the whole robotlegs context before you actually remove it. But... race conditions at unload can usually be avoided by explicitly deciding what needs to happen in what order and then calling that sequence of events.

    Stray

  4. Ondina D.F. closed this discussion on 05 Jan, 2012 09:07 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