使被设置为屏蔽点击并MouseEvents回应一个影片剪辑 [英] Making a Movieclip which is set as mask clickable and respond to MouseEvents

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

问题描述

我试图做一个影片剪辑的摇摄

I am trying to do panning of a movieclip

我在第二阶段的影片剪辑。 canvasPanel_mc和mask_mc。前者是maskee为掩模(mask_mc)。里面mask_mc有一个影片剪辑dragCanvas_mc。 dragCanvas_mc的α被设置为零。这是我使用code:

I have two movieclips on stage. canvasPanel_mc and mask_mc. The former is the maskee for the mask (mask_mc). Inside mask_mc there is a movieclip dragCanvas_mc. The alpha of dragCanvas_mc is set to zero. This is code that I am using:

mask_mc.dragCanvas_mc.addEventListener(MouseEvent.MOUSE_DOWN,onStartDrag);
mask_mc.dragCanvas_mc.addEventListener(MouseEvent.MOUSE_OUT,onStopDrag);
mask_mc.dragCanvas_mc.addEventListener(MouseEvent.MOUSE_UP,onStopDrag);

function onStartDrag(evt:MouseEvent)
{
 canvasPanel_mc.startDrag();
}
function onStopDrag(evt:MouseEvent)
{
 canvasPanel_mc.stopDrag();
}

我已经计算过,由于mask_mc被设置作为掩模的MouseEvents没有被登记。有没有什么办法,使其MouseEvents回应。或者我应该制定一些其他的方式。

I have figured that since the mask_mc is set as a mask the MouseEvents are not being registered. Is there any way to make it respond to MouseEvents. Or should I work out some other way.

推荐答案

你的层次结构应该寻找这样的:

the structure of your layers should be looking like this:

  • holder_mc
    • dragCanvas_mc
    • mask_mc
    • canvasPanel_mc
    • holder_mc
      • dragCanvas_mc
      • mask_mc
      • canvasPanel_mc

      然后:

      canvasPanel_mc.mask = mask_mc;
      

      当你设置mask_mc作为面膜canvasPanel_mc,然后mask_mc变成只是一个diplayobject,因此,这将绕过mouseEvents等..

      when you are setting mask_mc as mask for canvasPanel_mc, then mask_mc becomes just a diplayobject, so that it would bypass the mouseEvents and etc...

      那么你的code会这样看,这将拖累所有holder_mc的:

      then your code would be looking like this, it would drag all of the holder_mc:

      dragCanvas_mc.addEventListener(MouseEvent.MOUSE_DOWN,onStartDrag);
      
      function onStartDrag(evt:MouseEvent)
      {
          stage.addEventListener ( MouseEvent.MOUSE_UP,onStopDrag)
          startDrag();
      }
      function onStopDrag(evt:MouseEvent)
      {
          stage.removeEventListener( MouseEvent.MOUSE_UP,onStopDrag)
          stopDrag();
      }
      

      @pkyeck的解决方案是有效的太多,但只有当你有没有用户iteraction的canvasPanel_mc里面

      @pkyeck solution is valid too, but only when you have no user iteraction inside the canvasPanel_mc

      这篇关于使被设置为屏蔽点击并MouseEvents回应一个影片剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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