views:

95

answers:

1

I'm using Javascript to embed a flash file into a website which I then need to remove once it's completed playing.

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

How do I code this? ._.

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" /\>');
+1  A: 

Javascript has no native way to know when Flash is done playing. You can set a timer in javascript to remove it if the swf will always play for a set time or add an External Interface in flash to send a call to JS when its finished playing.

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

puppbits