SWF 文件在第二次循环后停止

发布于 2024-12-03 19:00:14 字数 694 浏览 5 评论 0原文

我有一个使用 Adob​​e 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一花一树开 2024-12-10 19:00:14

不要使用 setInterval,因为它会无限重复,特别是如果您在循环末尾继续创建间隔。使用 setTimeout 代替:

stop();
setTimeout(wait, 5000);
function wait(){
    gotoAndPlay(1);
}

Don't use setInterval because it's going to repeat indefinitely, especially if you keep creating interval at the end of your loop. Use setTimeout instead:

stop();
setTimeout(wait, 5000);
function wait(){
    gotoAndPlay(1);
}
金橙橙 2024-12-10 19:00:14

所以它到达结尾,停止,等待 10 秒,然后返回到开头,但在播放时,它仍在计算另外 10 秒,在此期间它将循环播放。

所以基本上使用

setTimeout(wait, 10000);

而不是

setInterval(wait, 10000);

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

setTimeout(wait, 10000);

rather than

setInterval(wait, 10000);
浅紫色的梦幻 2024-12-10 19:00:14

我建议命名您的 setInterval 并确保在启动之前先清除它,否则您可能会在那里遇到一些不需要的混乱循环。

stop();
clearInterval(my_interval);
my_interval = setInterval(wait, 10000);
function wait(){
    gotoAndPlay(1);
}

这样,当它再次进入第一帧时,它总是会清除任何先前的间隔,从而避免多个间隔。

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.

stop();
clearInterval(my_interval);
my_interval = setInterval(wait, 10000);
function wait(){
    gotoAndPlay(1);
}

That way it will always clear any previous interval when it goes to first frame again, avoiding multiple intervals.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文