我有这个功能,但...... 我想要 如果主要时间正在播放,那么它会进入框架并播放 和 如果主要时间是(不播放),那么它会进入帧并暂停
此功能用于主要时间的自定义滑块控件。
感谢;
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 :(得分: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影片剪辑的实例,则可以检查WatcherMC_instance.RootIsPlaying ..
var WatcherMC_instance:WatcherMC= new WatcherMC();
// use WatcherMC_instance.RootIsPlaying ..
我希望这会有所帮助!