Strange issue with MouseEvent

C's Avatar

C

22 Sep, 2011 11:51 AM

Hello,

in a MenuMediator i have this (onRegister overrided):

eventMap.mapListener(menu, MouseEvent.CLICK, onMenuClick);

The "onMenuClick" callback is called just few times (sometimes 5, sometimes 20) but then stop to be called. The MouseEvent is always fired because if i use the classic

menu.addEventListener(MouseEvent.CLICK,onMenuClick);

the function is always called at every click.

The eventMap works only if i have this tow lines togheter

eventMap.mapListener(menu, MouseEvent.CLICK, onMenuClick); menu.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) {});

so, i have to add a classic listener (also with a blank callback) and it always work.

What's happened?!

Thank you

  1. 1 Posted by Stray on 22 Sep, 2011 11:59 AM

    Stray's Avatar

    Hi C,

    any chance that you're not holding on to your Robotlegs Context? As in - are you setting it to a member variable, or are you just doing

    var context:Context = new SomeContext(...);

    ?

    You need to be doing:

    _someContext = new SomeContext(...);

    That's the usual cause of timing sensitive issues. I expect that the use of the anonymous function is what is keeping it working with the second handler - that won't be removed when the mediator is destroyed.

    If it's not that, we'll help you chase it down further,

    Stray

  2. 2 Posted by C on 22 Sep, 2011 12:57 PM

    C's Avatar

    You got it!

    I had this in my Main.as

    new MainContext(this);

    and now with

    _mainContext = new MainContext(this);

    all works correctly.

    Really thanx!

  3. Ondina D.F. closed this discussion on 01 Nov, 2011 04:30 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