Best Practice for stage listeners and mediators that use them.

mrcheeks's Avatar

mrcheeks

17 Jan, 2012 01:08 AM

Hi,

Just learning robotlegs. This is most probably a really basic question... sorry in advance, still grasping everything.
Say a mediator that controls a sliding/dragging gallery or video player etc.. wants to know when the mouse leaves the stage.
How do I get access to the stage in the mediator to add a listener? or is that not the best way/place to do it?

Thanks,
MrCheeks.

  1. Support Staff 1 Posted by Ondina D.F. on 17 Jan, 2012 09:19 AM

    Ondina D.F.'s Avatar

    Hey Mr. Cheeks,

    Just learning robotlegs. This is most probably a really basic question... sorry in advance, still grasping everything.

    No problem:)

    [Inject] public var view:ContextView;

    override public function onRegister():void
    {

    eventMap.mapListener(view.stage, Event.MOUSE_LEAVE, stage_mouseLeave);

    }

    private function stage_mouseLeave(event:Event):void
    {

    trace("stage_mouseLeave(event)");

    }

    or, you can let the view dispatch a custom event in its handler function of the MOUSE_LEAVE event and in onRegister the Mediator would listen for that event:
    addViewListener (SomeViewEvent.SOME_ACTION, someActionHandler);

    or, simply listen and re-dispatch it, if need be:
    addViewListener (SomeViewEvent.SOME_ACTION, dispatch);

    Ondina

  2. 2 Posted by mrcheeks on 17 Jan, 2012 11:28 AM

    mrcheeks's Avatar

    thankyou. :)

  3. 3 Posted by mrcheeks on 17 Jan, 2012 11:28 AM

    mrcheeks's Avatar

    how easy is that!

  4. Support Staff 4 Posted by Ondina D.F. on 17 Jan, 2012 12:26 PM

    Ondina D.F.'s Avatar

    You’re welcome!
    Enjoy robotlegs:)

  5. Ondina D.F. closed this discussion on 17 Jan, 2012 12:26 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