制作一个影片剪辑是下一个面具点击并MouseEvents回应 [英] Making a Movieclip which is under a mask clickable and respond to MouseEvents

查看:158
本文介绍了制作一个影片剪辑是下一个面具点击并MouseEvents回应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题的后续行动上链接的问题: <一href="http://stackoverflow.com/questions/6832117/making-a-movieclip-which-is-set-as-mask-clickable-and-respond-to-mouseevents">Making一个影片剪辑被设置为屏蔽点击和回复MouseEvents

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

  • holder_mc

  • dragCanvas_mc
  • mask_mc
  • canvas_mc

dragCanvas_mc - 用于平移puposes

dragCanvas_mc - used for panning puposes.

mask_mc - 面膜canvas_mc

mask_mc - Mask for canvas_mc

我现在面临的一个问题。我不能让MouseEvents上的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.

推荐答案

如果影片剪辑A'是在显示列表上方的影片剪辑B'和'影片剪辑A'是'将mouseEnabled,然后影片剪辑B'永远没有收到事件到上影片剪辑。

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.

在你的情况下,拖动画布之上,并且是最有可能连接到某些鼠标事件。如果是这样的话,你需要处理与顶级剪辑(拖动画布)的事件,并通过它们传递给孩子,还是家长,holder_mc。

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.

holder_mc.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void {
    // do normal clicky stuff for this object
    // then..
    //

    if(canvas_mc.hitTestPoint(mouseX, mouseY, false)) {
        // do clicky stuff for canvas mc
    }    

}

也许有人会说使用getObjectsUnderPoint',但有一个与它记录的错误,所以使用hitTestPoint()<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#hitTestPoint%28%29" rel="nofollow">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#hitTestPoint%28%29

这篇关于制作一个影片剪辑是下一个面具点击并MouseEvents回应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆