2013-03-19 69 views
0

我有這個功能,但是...... 我想 如果主時間打得那麼它去幀並播放 和 如果主要時間是(不是播放),所以它進入幀並暫停從影片剪輯(檢查主時間軸播放)在AS3

這個函數在主時間自定義滑塊控件。

謝謝;

sliderLine_mc.addEventListener(MouseEvent.CLICK,snapTO); 

function snapTO(event:MouseEvent) 

{ 
    if (sliderTrack.mouseX > 0 && sliderTrack.mouseX < 320) 
    { 
     sliderKnob.x = mouseX; 
     sliderKnob.x = MovieClip(root).currentFrame * (300/MovieClip(root).totalFrames); 


     if (MovieClip(root).isPlaying == true) 
     { 
      MovieClip(root).gotoAndPlay(Math.floor(mouseX/(300/MovieClip(root).totalFrames))-60); 

     } 
     else if (MovieClip(root).isPlaying == false) 
     { 
      MovieClip(root).gotoAndStop(Math.floor(mouseX/(300/MovieClip(root).totalFrames))-60); 

     } 




    } 
} 

回答

0

您可以創建一個觀察者的影片剪輯,將你想要做什麼:

public class WatcherMC extends MovieClip 
{ 

private var last_enter_frame:int= 0; 
private var root_animation_steps:int= 0; 
private var root_stoped_steps:int= 0; 
public RootIsPlaying:boolean= false; 
public function WatcherMC():void 
{ 
addEventListener(Event.ENTER_FRAME, onEnterFrame); 
} 


private function onEnterFrame(event:Event):void 
{ 
    if (MovieClip(root).currentFrame!= last_enter_frame) 
    { 

     root_animation_steps++; 
     if (root_animation_steps> 3) 
     { 
        root_stoped_steps= 0; 

        root_is_playing(); 
     } 
    } 
    else 
    { 
      root_stoped_steps++; 

      if (root_stoped_steps> 3) 
      { 
      root_animation_steps= 0; 
      root_is_still_not_playing(); 
      } 
    } 
     last_enter_frame= MovieClip(root).currentFrame; 
} 


private function root_is_playing():void 
{ 
// root is playing, do what ever I want 
RootIsPlaying= true; 
} 
private function root_is_still_not_playing():void 
{ 
// root is not playing, do what ever I want 
RootIsPlaying= false; 
} 

}

把你的代碼中的函數root_is_playingroot_is_still_not_playing 就可以檢查WatcherMC_instance.RootIsPlaying或者如果你實例化一個WatcherMC電影剪輯的實例..

是這樣的:

var WatcherMC_instance:WatcherMC= new WatcherMC(); 
// use WatcherMC_instance.RootIsPlaying .. 

我希望這會有所幫助!

+0

我已添加編輯,您可以在下面看到.. – simo 2013-03-19 09:17:13

+0

對不起,我是初學者,我沒有理解你,對不起...我需要一個簡單的想法,如果主要時間線工作去框架和工作,如果主要時間線不工作去和停止....簡單的想法爲微笑滑塊....再次感謝 – 2013-03-19 09:57:10

+0

沒問題:-)可能是你需要一個教程.. – simo 2013-03-19 10:45:45