我试图做一个影片剪辑的摇摄
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