Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flash AS3: How to prevent MouseEvent.MOUSE_OUT when you mouse_over a child sprite

All,

Here's my situation...

The UI of my Flash application is a grid. Each row of the grid is a sprite that contains a number of child sprites (UI controls) that respond to mouse events

Each row of the grid should have a hover effect - i.e., when you hover over the row, the row's background should change color.

This is accomplished easily:

rowSprite.addEventListener(MouseEvent.MOUSE_OVER, highlightRow, false, 0, true);
rowSprite.addEventListener(MouseEvent.MOUSE_OUT, unhighlightRow, false, 0, true);

This works fine, EXCEPT that when the user rolls over any of the row's child sprites, the row's MOUSE_OUT event is fired, and the row is "unhighlighted". This isn't what I want.

In other words - I'd like the row to be unhighlighted only when you roll OUTSIDE of the row, not when you roll over a child sprite within the row.

A possible solution: in the unhighlightRow function, test whether the user's mouse position is still within the row sprites bounds. But I'm guessing that's not the most elegant or efficient solution.

This must be an incredibly common problem. What's the best solution?

Thanks in advance!

like image 476
mattstuehler Avatar asked Dec 28 '25 03:12

mattstuehler


1 Answers

You can use ROLL_OVER and ROLL_OUT instead of MOUSE_OVER and MOUSE_OUT in such cases:

http://kinderas.blogspot.com/2008/12/quicktip-mouseover-vs-rollover.html

like image 70
Lars Blåsjö Avatar answered Dec 30 '25 23:12

Lars Blåsjö



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!