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