Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Trusted Contributor
PBDev
Posts: 108
Registered: ‎12-28-2010
My Device: Free PlayBook
My Carrier: Verizon

MouseEvent.MOUSE_UP event not firing all of the time

[ Edited ]

Hi all,

 

I have a strange problem. I'm hoping it's related to the speed of the simulator.

 

In my app I'm moving sprites around using this:

 

cardSprites[card].addEventListener(MouseEvent.MOUSE_DOWN, onDown);
cardSprites[card].addEventListener(MouseEvent.MOUSE_UP, onUp);
addChild(cardSprites[card]);

private function onDown(e:MouseEvent):void
{
	b = Sprite(e.currentTarget);

	...

	b.filters = [ new DropShadowFilter( ) ];
	addChild(b);

	b.startDrag(false, new Rectangle(0, 0, 1024 - CARD_WIDTH, 594 + CARD_HEIGHT));
}

private function onUp(e:MouseEvent):void
{
	b.stopDrag();

	...
}

 

 

It works most of the time but once out of maybe 100 or 200 times the MouseEvent.MOUSE_UP event doesn't fire and the mouse won't stop draging the sprite around. When it does this the mouse cursor stops moving for just an instance after I click on the sprite to move. Before I added the DropShadowFilter() filter everything was working.

 

I think it has something to do with the simulator because it doesn't do it all of time. It would be nice to have a real PlayBook to test this theory.

 

I would hate to have to remove the drop shadow effect.

 

Any ideas guys?

 

Thanks

 

Please use plain text.
Developer
EraserX
Posts: 168
Registered: ‎01-13-2011
My Device: Not Specified

Re: MouseEvent.MOUSE_UP event not firing all of the time

Possibilities I can think of why a mouse_up might not register:

 

  1. The mousebutton is released while the cursor is outside the bounds of the simulator
  2. The mousebutton is release while the cursor is outside the bounds of cardSprites[card] object (note that in many circumstances, transparent portions of objects do not receive mouse events.  I don't know what all the circumstances are, but look into it if it is applicable).  In other instances, the transaprent portions of other objects may be catching your events.  I find it useful to .graphics.beginfill(0,0.5) [50% transp] and drawRect(w,h) to debug where objects may be inadvertently overlapping
  3. The mouseUP event occurs while the cursor is on top of a different object which is in front of cardSprites[card] and which is not a child of cardSprites[card]
  4. The mouseUp event occurs on a child of cardSprites[card] which is stopping propagation for the mouseUp event.  Note, that I have found that some of the QNX objects stop propagation for certain mouse events.  Look into it if applicable. Try disabling mouseChildren and mouseEnabled on objects that don't require mouseevents to ensure they are not interfereing.
Please use plain text.
Trusted Contributor
PBDev
Posts: 108
Registered: ‎12-28-2010
My Device: Free PlayBook
My Carrier: Verizon

Re: MouseEvent.MOUSE_UP event not firing all of the time

Hi EraserX,

 

Thanks for the help.

 

The problem I'm having is similar to 1 but it doesn't happen when I go outside of the bounds of the simulator. Every time I release the mouse button outside of the simulator bounds and come back into the simulator the sprite will move with the mouse but the problem I'm having happens when I don't go outside of the bounds of the simulator. 2 is interesting. I'll have to look into that but that's not what's happening here. 3 - I'm using addChild to bring the sprite to the top of the display list before .startDrag so I don't think that's the problem. 4 - In my app there are times when I'm dragging a stack of sprites but this has never happen with a stack, only when I'm dragging one sprite.

 

Thank for the suggestions. When I get this problem fixed I'll be finished with this app.

Please use plain text.