开发者

AS3 Movieclip not responding to Mouse_Wheel event

I'm creating a container as a MovieClip and adding a mousewheel handler, then adding items to it like so:

container = new MovieClip();        
addChild( container );
container.addEventListener( MouseEvent.MOUSE_WHEEL, HandleWheel );
container.addChild( item );
// etc. adding more items 

However the mousewheel is only responding when the mouse is over one of the items, not ove开发者_如何学编程r the visible areas of the container between the items. Is there any way to make it so the event is always triggered when the mouse is over the container, not just over its children?

I don't know if it's relevant, but the container has a mask set. I tried adding the listener to the mask and it didn't do anything, though.

If I set the opaqueBackground of the container to red, I can see the container bounds. I don't understand why the mouse wheel event isn't triggering when the mouse is within these bounds. If this is really not possible, is there another way to handle the situation without needing the container to respond directly to mouse events?

Thanks for any help.


"The opaque background region does not respond to mouse events."

From: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#opaqueBackground


You may need to add a rectangle to the background to act like a bounding box. It can have its alpha set to 0%. The problem is that if the cursor is on a completely transparent area of the object, it will just not pass mouse events to it, as it shouldn't (otherwise we'd always be stuck with rectangular areas); in that case, adding the transparent backgrounds fixes it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜