SWF 文件在第二次循环后停止
我有一个使用 Adobe Flash Professional CS5.5 创建的 swf 文件,它是一些带有音频的鸟类的基本动画,它意味着每 5 秒回复一次,但由于某种原因,在开始播放第二个循环后它停止了中途并从头开始播放视频。谁能帮我解决这个问题吗?
这是我的动作脚本:
stop();
setInterval(wait, 10000);
function wait(){
gotoAndPlay(1);
}
这是我将电影嵌入到 html 页面上的 javascipt:
<script type="text/javascript" src="/js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("/js/birdmovie.swf", "myAlternative", "290", "163", "9.0.0", "/js/expressInstall.swf", flashvars, params, attributes);
</script>
I have a swf file which I created using Adobe Flash professional CS5.5, it's a basic animation of some birds with an audio, it is meant to reply every 5 seconds, but for some reason after it starts to play the second loop it stops mid way and restarts the video from the beginning. Can anyone help me fix this?
This is my actionscript:
stop();
setInterval(wait, 10000);
function wait(){
gotoAndPlay(1);
}
This is my javascipt to embed the movie on an html page:
<script type="text/javascript" src="/js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
params.wmode = "transparent";
var attributes = {};
swfobject.embedSWF("/js/birdmovie.swf", "myAlternative", "290", "163", "9.0.0", "/js/expressInstall.swf", flashvars, params, attributes);
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不要使用 setInterval,因为它会无限重复,特别是如果您在循环末尾继续创建间隔。使用
setTimeout
代替:Don't use
setInterval
because it's going to repeat indefinitely, especially if you keep creating interval at the end of your loop. UsesetTimeout
instead:所以它到达结尾,停止,等待 10 秒,然后返回到开头,但在播放时,它仍在计算另外 10 秒,在此期间它将循环播放。
所以基本上使用
而不是
so it gets to the end, stops, waits 10 seconds and then goes back to the beginning, but while it's playing, it's still counting another 10 seconds, in which it will loop.
So basically use
rather than
我建议命名您的 setInterval 并确保在启动之前先清除它,否则您可能会在那里遇到一些不需要的混乱循环。
这样,当它再次进入第一帧时,它总是会清除任何先前的间隔,从而避免多个间隔。
I would recommend to name your setInterval and make sure you clear it first before starting it, otherwise you might get some unwanted confusing loops there.
That way it will always clear any previous interval when it goes to first frame again, avoiding multiple intervals.