2013-03-25 23 views
0

幫助!!如何在父母的孩子身上停止父級動畫片段的功能?

我在一個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

其實目前還不清楚你想要達到的目標。你可以更具體嗎? – Teejay 2013-03-25 11:49:33

+0

spinY_mc內有35個電影剪輯1-35每個mc是一個產品的不同角度。我寫了一些代碼,當拖動鼠標時,它會播放這些影片剪輯,並給出產品旋轉的印象,以便您可以看到所有角度。 – Danielle 2013-03-25 15:18:52

+0

其中兩個角度說1_mc和35_mc我有更多的動畫,你可以與之交互。但是,當我在電影剪輯的這一部分內im我不想能夠拖動我如何刪除我的孩子movieclip內的父級動畫片段的功能? – Danielle 2013-03-25 15:22:12

回答

0

我敢肯定,你只是想停止從孩子的事件的傳播,所以它不會出來給父母。如果您爲要阻止的事件添加偵聽器(可以說它是要阻止的mouseDown)。

child_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownBlocker); 

private function mouseDownBlocker(event:MouseEvent):void 
{ 
    event.stopImmediatePropagation(); 
} 

的方式工作的事件是他們開始在「deepeest」孩子該鼠標擁有一擊事件,那麼他們的「泡沫」,貫穿所有的父母。通過阻止傳播阻止冒泡的發生,所以父母從未得到事件。

+0

我想在孩子時停止父母的功能,但我無法從孩子內部引用父母的功能?我怎麼做? – Danielle 2013-03-27 11:03:37

+0

通過添加此代碼,我不能再拖動第一個影片剪輯? ... confused:/ – Danielle 2013-03-27 11:09:14

+0

我想我可能已經發現我的問題,我用來拖動並播放最初的mc(spinY_mc)的函數尋找stage.mouseY當我在我的孩子movieclip中如何停止使用此函數AWComplete_mc)?我不能在這裏發佈文件,因爲我的公司不會允許它,但我可以發佈代碼,我該怎麼做? – Danielle 2013-03-27 12:40:33

相關問題