[英]How to detect a flash movie has finished playing with javascript / jquery and then run a function
I need to create a splash page type thing. 我需要创建一个初始页面类型的东西。 It needs to play a flash movie and then when that movie has finished show a full screen image using html/js.
它需要播放Flash电影,然后在完成电影播放后使用html / js显示全屏图像。 THe movie will be flash and the image display will be javascript powered.
电影将闪烁,并且图像显示将由javascript驱动。
I have no idea how to do this on one page. 我不知道如何在一页上执行此操作。 Any help would be amazing.
任何帮助都将是惊人的。
Thank you for reading. 感谢您的阅读。
You'll want to use ExternalInterface . 您将要使用ExternalInterface 。 Example:
例:
try {
ExternalInterface.call("myfunction");
} catch(e:Error) {
trace(e)
}
Depending on how your flash movie is constructed, when the animation reaches the last frame, running ExternalInterface.call("myfunction"); 取决于Flash电影的构造方式,动画到达最后一帧时,运行ExternalInterface.call(“ myfunction”);。 will call a function in javascript called "myfunction".
将在javascript中调用一个名为“ myfunction”的函数。 Example:
例:
<script type="text/javascript">
function myfunction()
{
alert("hello!"); // replace with some jquery
}
</script>
I can't really say how to put it into your movie, because I don't know if your movie is constructed using actionscript animation, or timeline animation, or you're wanting to play a flash video. 我真的不能说如何将其放入电影中,因为我不知道您的电影是使用动作脚本动画还是时间轴动画构造的,还是您想播放Flash视频。 (If you are using a video, you can attach an event listener for Event.COMPLETE and do your c all there).
(如果您使用的是视频,则可以为Event.COMPLETE附加一个事件侦听器,然后在其中进行所有操作)。 If its an actionscript animation, you'll need to find the end of a tween or something.
如果是动作脚本动画,则需要查找补间的结尾或其他内容。 Wrapping it in a try/catch is just to be safe.
将它包装在try / catch中只是为了安全起见。 You'll need to make sure when you embed the swf, you have allowScriptAccess=always or sameDomain.
您需要确保在嵌入swf时具有allowScriptAccess = always或sameDomain。 Reference here
这里参考
There may be a better way to do this, but inside the flash movie you can use ExternalInterface to call javascript functions. 也许有更好的方法,但是在Flash电影中,您可以使用ExternalInterface调用javascript函数。 So, you can set up an actionscript function to run when the movie ends, and have it a call a javascript function to do whatever you need to do with the web site.
因此,您可以设置一个动作脚本函数以在电影结束时运行,并让它调用javascript函数以执行与网站有关的任何操作。
-- Disclaimer -- I don't have the cash to upgrade my Flash, so I'm still using actionscript 2. The object I mentioned may be deprecated now - but it will still work. -免责声明-我没有钱升级我的Flash,因此我仍在使用动作脚本2。我提到的对象现在可能已被弃用-但它仍然可以使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.