Detecting when Flash file has finished playing in Javascript

I am using Javascript to embed a flash file into a website, which I then need to delete after it completes.

Is there a way to do this in plain Javascript? Or will it require the callback type function to be added to the Flash file itself?

How to do it?._.

JavaScript:

jQuery('body').append('<embed id="flashIntro" width="100%" height="100%" type="application/x-shockwave-flash" src="' + flashIntro + '" pluginspage="http://www.adobe.com/go/getflashplayer" /\>');

      

+2


a source to share


1 answer


Javascript has no way of its own to know when Flash is running. You can set a timer in javascript to remove it if swf will always play for a set time, or add an external interface in flash to send a JS call when it finishes playing.



Add this to the last frame of the swf or to your destroy function:
import flash.external.ExternalInterface; if (ExternalInterface.available) ExternalInterface.call("JavaScriptFunctionNameToCallWhenDone", true);

+1


a source







All Articles