帮助!!
我在mc上有一段代码,当鼠标被拖动时,它会播放该影片剪辑,从而实现产品的360度旋转。
在360度旋转的不同增量的这个动画片段中,我有儿童动画片段,其中包含与产品的每个角度相关的各种其他动画。
EXP ..
场景1> spinY_mc> AWComplete_mc
我的旋转代码是在scene1中的动作中编写并控制spinY_mc,但是一旦我在AWComplete_mc中,我不希望你能够拖动鼠标并旋转?
我确信这很简单,但我是一个菜鸟,我正在接受一个庞大的项目!
以下是movieclip(spinY_mc)上使用的代码我不希望此代码在其子mc(AWComplete_mc)内部工作。
// Rotation of Control Body Y
spin_Y.stop();
spin_Y.buttonMode = true;
var spin_Y:MovieClip;
var offsetFrame:int = spin_Y.currentFrame;
var offsetY:Number = 0;
var percent:Number = 0;
spin_Y.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
spin_Y.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
function startDragging(e:MouseEvent):void
{
// start listening for mouse movement
spin_Y.addEventListener(MouseEvent.MOUSE_MOVE,drag);
offsetY = stage.mouseY;
}
function stopDragging(e:MouseEvent):void
{
// STOP listening for mouse movement
spin_Y.removeEventListener(MouseEvent.MOUSE_MOVE,drag);
// save the current frame number;
offsetFrame = spin_Y.currentFrame;
}
// this function is called continuously while the mouse is being dragged
function drag(e:MouseEvent):void
{
// work out how far the mouse has been dragged, relative to the width of the spin_Y
// value between -1 and +1
percent = (mouseY - offsetY) / spin_Y.height;
// trace(percent);
// work out which frame to go to. offsetFrame is the frame we started from
var frame:int = Math.round(percent * spin_Y.totalFrames) + offsetFrame;
// reset when hitting the END of the spin_Y timeline
while (frame > spin_Y.totalFrames)
{
frame -= spin_Y.totalFrames;
}
// reset when hitting the START of the spin_Y timeline
while (frame <= 0)
{
frame += spin_Y.totalFrames;
}
// go to the correct frame
spin_Y.gotoAndStop(frame);
}
答案 0 :(得分:0)
我很确定你只是想阻止孩子传播一个事件,所以它不会传递给父母。如果为要阻止的事件添加一个侦听器(假设它是要阻止的mouseDown)。
child_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownBlocker);
private function mouseDownBlocker(event:MouseEvent):void
{
event.stopImmediatePropagation();
}
事件的工作方式是他们从“最深”的孩子开始,鼠标有一个命中事件,然后他们通过所有父母“冒泡”。通过停止传播,你可以阻止冒泡,所以父母永远不会得到这个事件。