制作蒙版下的影片剪辑可点击并响应 MouseEvents
这个问题是链接上问题的后续问题: 制作已设置的影片剪辑作为可点击的掩码并响应 MouseEvents
我在舞台上的图层结构如下所示:
holder_mc
- dragCanvas_mc
- mask_mc
- canvas_mc
DragCanvas_mc - 用于平移目的。
mask_mc - canvas_mc 的掩模
我现在面临一个问题。我无法在 canvas_mc 上注册 MouseEvents
这是必需的,因为我必须在画布上绘图,
holder_mc.canvas_mc.addEventListener(MouseEvent.MOUSE_DOWN,onStartDrawing);
function onStartDrawing(evt:MouseEvent)
{
trace("Hello");
}
我在输出窗口中看不到 Hello。知道我哪里错了。提前致谢。
This question is a follow up to the questions on link:
Making a Movieclip which is set as mask clickable and respond to MouseEvents
The structure of your layers that I have on stage looks like this:
holder_mc
- dragCanvas_mc
- mask_mc
- canvas_mc
dragCanvas_mc - used for panning puposes.
mask_mc - Mask for canvas_mc
I am facing a problem now. I cannot get MouseEvents to be registered on the canvas_mc
This is required because I have to make drawings to the canvas
holder_mc.canvas_mc.addEventListener(MouseEvent.MOUSE_DOWN,onStartDrawing);
function onStartDrawing(evt:MouseEvent)
{
trace("Hello");
}
I cannot see Hello in output window. Any idea where I am wrong. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果“MovieClip A”在显示列表上位于“MovieClip B”之上,并且“MovieClip A”为“mouseEnabled”,则“MovieClip B”将永远不会“通过”顶部 MovieClip 接收事件。
在您的情况下,拖动画布位于上方,并且很可能附加到某些鼠标事件。如果是这种情况,您需要使用顶部剪辑(拖动画布)处理事件并将它们传递给子级或父级 Holder_mc。
有些人可能会说使用“getObjectsUnderPoint”,但它有一个已记录的错误,因此请使用 hitTestPoint() http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#hitTestPoint%28%29
If 'MovieClip A' is above 'MovieClip B' on the display list and 'MovieClip A' is 'mouseEnabled' then 'MovieClip B' will never receive the events "through" the top MovieClip.
In your case, the drag canvas is above, and is most likely attached to some mouse events. If this is the case, you need to handle the events with the top clip (drag canvas) and pass them through to the children, or the parent, holder_mc.
Some people might say use 'getObjectsUnderPoint' but there is a documented bug with it, so use hitTestPoint() http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#hitTestPoint%28%29
可能是您的 mask_mc 正在拦截鼠标事件。您可以尝试此测试来查看谁在触发
MouseEvent.CLICK
。如果它是 mask_mc 或其他某个影片剪辑,您可以将该影片剪辑的
mouseEnabled
设置为 false,MouseEvent
将忽略它。It could be that your mask_mc is intercepting the mouse events. You can try this test to see who is firing the
MouseEvent.CLICK
.If it is the mask_mc or some other movie clip you can set
mouseEnabled
to false for that movie clip and theMouseEvent
will ignore it.