Detecting MouseEvents for object below another object

1.2k views Asked by At

So basically, I have a large movieclip, lets call it "hit" and a bunch of smaller "thumb" movieclips below it. I have ROLL_OVER and ROLL_OUT event listeners on the main "hit" movieclip that I use to position the thumbs correctly (the component is a kind of ticker).

I am having a problem with getting the ROLL_OVER, ROLL_OUT, and CLICK event listeners to fire on the "thumb" movieclips that are below "hit".

Right now I am using a hit test, which kind of works, but I'd like a simpler way. I am an actionscript-3 newbie so any help would be appreciated. Thanks!

2

There are 2 answers

0
puggsoy On

This thread appears to be asking the same question. The solution including getObjectsUnderPoint seems to be the best choice.

0
Kolyunya On

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html#!flash/display/InteractiveObject.html#event:rollOver

Dispatched when the user moves a pointing device over an InteractiveObject instance. The event target is the object under the pointing device or a parent of that object. The relatedObject is the object that was previously under the pointing device. The rollOver events are dispatched consecutively down the parent chain of the object, starting with the highest parent that is neither the root nor an ancestor of the relatedObject and ending with the object.

Object under hit won't dispatch ROLL_OVER event if it's not a parent of hit. Only objects on top will dispatch it. Mouse cursor must literally touch the object. If there is something between cursor and object, event won't be dispatched.