开发者

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. THe movie will be flash and the image display 开发者_如何学Pythonwill be javascript powered.

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. 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"); will call a function in javascript called "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. (If you are using a video, you can attach an event listener for Event.COMPLETE and do your c all there). 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. You'll need to make sure when you embed the swf, you have allowScriptAccess=always or 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. 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.

-- 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜