Access SWF and call Actionscript functions from Javascript in IE in Facebook after Facebook dialog pops up

132 views Asked by At

I'm developing a Facebook game using Flash and Starling and most of the time when a user on IE opens a Facebook Dialog (share/feed/send) I'll lose my ability to make Actionscript calls on the SWF object from Javascript.

As in before the dialog comes up, if I use something like this:

swfObj = document.getElementById('mySWF');
swfObj.talkToClient();

It works fine and after the dialog is shown, I start getting this error:

Object doesn't support property or method 'talkToClient'

It's as if IE forgets that that element is an SWF object or at least forgets about the SWF object callbacks.

I'm embedding Flash using swfobject with these values:

        var swfVersionStr = "14";                        
        var xiSwfUrlStr = "playerProductInstall.swf";
        var flashvars = {};
        var params = {};
        params.quality = "high";
        params.bgcolor = "#000000";
        params.allowscriptaccess = "always";
        params.allowfullscreen = "true";
        params.allowNetworking = "all";
        params.menu = "false";
        params.wmode = "direct";
        var attributes = {};
        attributes.id = "mySWF";
        attributes.name = "mySWF";
        attributes.align = "middle";

        swfobject.embedSWF(
            "index.swf", "flashContent",
            "827", "620",
            swfVersionStr, xiSwfUrlStr,
            flashvars, params, attributes, swfCallback);           
        swfobject.createCSS("#flashContent", "display:block;text-align:left");  

Any help will be greatly appreciated! :)

1

There are 1 answers

0
vonscharten On

I solved this by overriding Facebook's swf hiding behavior in Internet Explorer using the following css piece:

*::-ms-backdrop,#mySWF{
    visibility: visible !important;
}    

I'm leaving it here as it might help someone else. It seems like Internet Explorer doesn't like executing a javascript call to an swf obj that is not being shown and if by any chance you make it visible again after making ONE call to a hidden swf, IE continues not being able to execute it.

By not letting the swf object to be hidden, everything works fine :)