I have a special canvas class covering my entire stage, and a bunch of Sprite hotspots on the layer below. If I put the hotspots on the same layer as my canvas, the canvas does not register MOUSE_DOWN events if my mouse is inside one of the hotspots, since the hotspots are targeted instead. However, if I keep the hotspots on the lower layer, the canvas handles all the MouseEvents. Is there any way to make MouseEvents target more than one thing, so that both the canvas and hotspots respond to MouseEvents? (The canvas is a bitmap drawing class and the hotspots are supposed to trigger when the cursor touches them or clicks on them.)
views:
489answers:
2ActionScript has both event bubbling and event capturing. This means you can listen for events starting on containing elements or on children elements. You just need to create the right kind of event listener. Capturing starts catching events at the parent elements as it moves down the chain of the children until it reaches the element where the event was triggered. Event bubbling starts listening for events at the child and moves up to the parent.
The third argument to addEventListener
, useCapture, determines if you want bubbling or capturing.
It sounds like you want event bubbling, so you want to set useCapture to false. Event listeners will be triggered on the child and on the parent.
apphacker got it right.
There a two other things you might be interested:
the mouseChildren property and the getObjectsUnderPoint() method
good luck