Skip to main content
Inspiring
August 21, 2012
Question

MouseEvent.MOUSE_MOVE listener won't remove

  • August 21, 2012
  • 1 reply
  • 396 views

Hey All,

So this is an event chain issue. I'll try to discribe it best I can. I'm going to have to put a work around in for now but here it goes.

I have an object called scroller. Scroller moves in either a horizontal or vertial direction. Scroller can container other scrollers as children up to one depth and moving in the opposite direction as the parent.

Scrollers can only move in one direction at a time and require the user to MouseUp and MouseDown to re-engage direction lock.

Direction lock is determined via the greater displacement of X over Y from the Origin point.

Displacement checking runs on both objects but starts at the child of the chain.

1.) Child.MOUSE_MOVE 

2.) Parent.MOUSE_MOVE   

If the childs fires the direction lock first. The parent gets and event to stop displacement checking.

Child.MOUSE_MOVE;

Child.dispatchEvent(Parent.STOP_CHECKING)

Parent.removeEventListener(MOUSE_MOVE)

Parent.MOUSE_MOVE;

If you notice from the above the parent still listens for the MouseMove event. It took a while to figure out that the removeEventListener does not actually work. At first I thought the events were doubled up somehow even though AS3 doesn't really allow for that anymore but the following created an endless loop and that's when I realized the listener would not be removed.

while(Parent.hasEvent(MOUSE_MOVE))

   Parent.removeEventListener(MOUSE_MOVE)

Is this a bug or does it have something to do with the Parents.MOUSE_MOVE already being queued in the event chain of things? I can see that happening but I don't know why the listener would not be able to be removed. I'm also planning on creating a bug ticket but I figure I'd ask here because more people respond to these.

This topic has been closed for replies.

1 reply

chris.campbell
Legend
August 22, 2012

Would you mind opening a bug report on this so we can do some investigation here?  If possible, please include sample code or project to help us quickly reproduce the problem.

Thanks,

Chris