加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flash swf、mc播放完毕的检测和判断

发布时间:2020-12-15 17:53:55 所属栏目:百科 来源:网络整理
导读:老问题 1 判断currentFrame? ?与totalFrame 2 在被加载文件中发出事件,侦听之 3 用addFrameScript 给被加载文件最后一帧添加代码。 1)如何检测一个MC里面的帧 播放完 毕? 1)mc.addFrameScript(mc.totalFrames-1,output) function output() { ? ? ? ? tra


老问题

1 判断currentFrame? ?与totalFrame
2 在被加载文件中发出事件,侦听之
3 用addFrameScript 给被加载文件最后一帧添加代码。

1)如何检测一个MC里面的帧播放完毕?

1)mc.addFrameScript(mc.totalFrames-1,output)
function output()
{
? ? ? ? trace("end")
}
2)mc.addEventListener(Event.ENTER_FRAME,onEnter);
function onEnter(e:Event):void {
? ? ? ? ? ? ? ? if (e.target.currentFrame==e.target.totalFrames) {
? ? ? ? ? ? ? ? trace("ok")
? ? ? ? }
}

2)如何检测一个swf的帧播放完毕?


前些天看到有人想要这样的类,我做了一个简单的类。
package mypkg?
{
? ? ? ? import flash.display.MovieClip;
? ? ? ? import flash.events.Event;
? ? ? ? import flash.events.EventDispatcher;
? ? ? ??
? ? ? ? /**
? ? ? ???* ...
? ? ? ???* @author DefaultUser (Tools -> Custom Arguments...)
? ? ? ???*/
? ? ? ? public class PlayComplete extends EventDispatcher
? ? ? ? {
? ? ? ? ? ? ? ? public static const PLAY_COMPLETE:String = "play complete";
? ? ? ? ? ? ? ? private var mc:MovieClip;
? ? ? ? ? ? ? ? public function PlayComplete(m:MovieClip)?
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? this.mc = m;
? ? ? ? ? ? ? ? ? ? ? ? this.endFrame();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? private function endFrame():void
? ? ? ? ? ? ? ? ? ? ? ? this.mc.addFrameScript(this.mc.totalFrames - 1,run);
? ? ? ? ? ? ? ? private function run():void
? ? ? ? ? ? ? ? ? ? ? ? //this.mc.stop();
? ? ? ? ? ? ? ? ? ? ? ? this.dispatchEvent(new Event(PLAY_COMPLETE));
? ? ? ? }? ? ? ??
}
下面是测试代码:
import??mypkg.PlayComplete;
var pc:PlayComplete = new PlayComplete(mc);//mc为播放动画的元件
pc.addEventListener(PlayComplete.PLAY_COMPLETE,printStr);//printStr里为你想要执行的代码
function printStr(eve:Event):void
? ? ? ? //mc.stop();//看你是否需要停止播放动画
? ? ? ? trace("test success");
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读