0

我有这个功能,但是......我想如果主要时间正在播放,所以它进入框架并播放,如果主要时间是(不播放),那么它进入框架并暂停

这个函数主要用于自定义滑块控件。

谢谢;

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);

        }




    }
}
4

1 回答 1

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_playing,然后root_is_still_not_playing 您可以检查 WatcherMC_instance.RootIsPlaying 是否实例化 WatcherMC 影片剪辑的实例。

像这样:

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

我希望这个能帮上忙!

于 2013-03-19T09:09:17.170 回答