2013-02-13 88 views
0

我有一隻綿羊的movieclip符號(符號名稱:「綿羊」)。這在整個屏幕上呈現出動畫效果。在羊電影剪輯裏面,有一些雙腿在上下移動。當羊停止移動時,我想腿也停止動畫。一旦父動畫完成,停止從父級到子級動畫片的動畫

我試圖從移動的函數內部訪問腿:

function sheepMove6() { 
    var sheepMoveX6:Tween = new Tween (inst_sheep, "_x", Strong.easeOut, 900, 850, 10, false); 

    sheepMoveX6.onMotionFinished = function() { 
     sheep.leg1MoveY.stop(); 
    } 
} 

我也試着檢測動畫從羊影片剪輯中整理:

_root.sheepMoveX6.onMotionFinished = function() { 
    leg1MoveY.stop(); 
} 

這些似乎都沒有阻止雙腿移動,一旦羊達到目的地。我正在使用AS2。

- 編輯 -

不知道如何定位影片剪輯我已經嘗試幾種不同的方式來訪問它的孩子,下面,還沒有工作。注:leg1MoveY爲補變量

_root.inst_sheep.inst_leg1.leg1MoveY.stop(); 
_root.inst_sheep.inst_leg1.stop(); 
_root.inst_sheep.stop(); 
_root.inst_sheep.inst_leg1.stop(); 
_root.inst_leg1.stop(); 
this.inst_sheep.inst_leg1.leg1MoveY.stop(); 
this.inst_sheep.inst_leg1.stop(); 
this.inst_sheep.stop(); 
this.inst_sheep.inst_leg1.stop(); 
this.inst_leg1.stop(); 

回答

0

我不能完全告訴你電影的結構的名稱,但我懷疑你只是在inst_leg1聲明leg1MoveY一個函數內。如果是這樣,leg1MoveY只能從內部訪問(其「範圍」僅限於該功能)。聲明它之外的功能(我猜什麼LEG1一樣):

var leg1MoveY:Tween; 

function legMove() { 
    leg1MoveY = new Tween(... // Tween settings 
} 

然後你嘗試的第一個行應當工作:

inst_sheep.inst_leg1.leg1MoveY.stop(); 

這裏有一篇關於scope in ActionScript 2可能的幫助。

+0

謝謝,文章非常有用 – Fisu 2013-02-14 09:03:14