I have some actionscript that plays a movie clip. When the movie clip is over I want Javascript to remove the Flash object from the page. I can't seem to get it working.
When I test the actionscript in Flash I don't get any compilation errors, and my Traces all execute when I expect. I also don't get any javascript errors thought the RemoveFlash() function never gets called.
Here's my ActionScript3:
import fl.video.*;
import flash.external.ExternalInterface;
MyPlayer.addEventListener(VideoEvent.COMPLETE, completePlay);
MyButton.addEventListener(MouseEvent.MOUSE_DOWN, interruptPlay);
function completePlay(e:VideoEvent):void
{
trace("video completed");
ExternalInterface.call("RemoveFlash");
}
function interruptPlay(e:MouseEvent):void
{
trace("video interrupted");
MyPlayer.stop();
ExternalInterface.call("RemoveFlash");
}
And here is my JS:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript" src="/Scripts/jquery-1.5.min.js"></script>
<script type="text/javascript" src="/Scripts/swfobject2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// Remove GreenPlayer
function RemoveFlash()
{
alert("remove");
$("#GreenPlayer").remove();
}
// add greenscreen swf
var flashvars = {};
flashvars.AllowScriptAccess="always";
var params = {};
params.wmode = "transparent";
params.AllowScriptAccess = "always";
swfobject.embedSWF("/swf/GreenPlayer2.swf", "GreenPlayer", "200", "400", "8.0.0", '', flashvars, params);
});
</script>
</head>
<body>
<div id="GreenPlayer">asd</div>
</body>
</html>
Any Thoughts?
$(document).ready(function(){});, what happens?