I'm using Javascript to call a method on a Flash movie embedded in an ASPX page using SWFObject. It works fine in Firefox, but Internet Explorer 7 and 8 (so far) claim the object returned by swfobject.getObjectById()
"doesn't support this property or method". I've found similar posts on this site and others, but nothing I've tried has fixed this in IE.
ActionScript 3.0 class:
public class Player extends MovieClip {
public function Player()
{
Security.allowDomain("http://localhost");
ExternalInterface.addCallback("test", test);
}
public function test():void
{
debugBox.appendText("test() called successfully\n");
}
}
ASPX markup:
<head runat="server">
<script type="text/javascript" src="Scripts/swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myPlayer", "9.0.0", "scripts/expressInstall.swf");
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="movie">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="640" height="640" id="myPlayer">
<param name="movie" value="Player.swf" />
<param name="allowscriptaccess" value="always" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="Player.swf" width="640" height="640">
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
Further along in the ASPX markup, the code that's trying to get the Flash object and call the test()
method on it is happening in an AJAX callback from a third-party component (DevExpress ASPxHiddenField). This callback is triggered by user input after the Flash movie is loaded:
<dx:ASPxHiddenField ID="filenameHiddenField" runat="server" OnCustomCallback="filenameHiddenField_CustomCallback"
SyncWithServer="False">
<ClientSideEvents EndCallback="function(s, e) {
var playerObject = swfobject.getObjectById("myPlayer");
playerObject.test();
}" />
</dx:ASPxHiddenField>
Internet Explorer complains about the last line in that function, "Object doesn't support this property or method".
Thanks!
It turns out Capabilities.isDebugger() is the culprit. I had omitted this from my original post for brevity (and because I thought there's no way it should matter), but the constructor in my ActionScript class actually looks like this:
public function Player()
{
Security.allowDomain("localhost");
if (!Capabilities.isDebugger)
{
ExternalInterface.addCallback("test", test);
}
}
I added that check because the ExternalInterface.addCallback()
throws "Error: Error #2067: The ExternalInterface is not available in this container. ExternalInterface requires Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime." when executed in the Flash debugger.
So apparently the Flash player in Internet Explorer is a debug version; ExternalInterface.addCallback()
was never getting called.