开发者

External Interface Calls To Flash Not Working in IE9

开发者 https://www.devze.com 2023-02-07 13:11 出处:网络
We have a flash game embedded in a web page (using SWFObject v2.2) and there are some links on the page that call into the flash in the following manner:

We have a flash game embedded in a web page (using SWFObject v2.2) and there are some links on the page that call into the flash in the following manner:

window.document["flashObjectId"].flashMethod();

This has worked great on all browsers we have tried including IE7 and 8, however on IE9 it generates the following error: "SCRIPT438: Object doesn't support this property or method".

It does work in compatibility mode so I tried adding a meta tag to tell IE9 to use compa开发者_如何学Gotibility mode by default, however that didn't work because our game runs in an IFrame within Facebook.

I have tried referencing the flash object every way I could think of in the Javascript but I always get that same error message in IE9. If anyone has any information that could help me get this to work in IE9 I would really appreciate it!


This is probably the reason for your problem and solution is also provided here:

http://msdn.microsoft.com/en-us/library/gg622942%28v=VS.85%29.aspx


I had same problem, but i did not use SWFObject or AC_RunActiveContent.js.

My solution was: swf published with HTML and AC_RunActiveContent.js. Then i replaced my current code with exported from flash and it started working.


What do you think about this?

function getFlashObject(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        //alert("IE");
        if (typeof (window[movieName].flashMethod) == 'function') {
            // < IE9
            movie = window[movieName];
        }
        else if (typeof (document[movieName].flashMethod) == 'function') {
            // >= IE9
            movie = document[movieName];
        }
    }
    else {
        // NON IE
        movie = document[movieName];
    }

    return ((movie) ? true : false);
}

$(document).ready(function () {
    if(getFlashObject("flashObjectId")) {
        movie.flashMethod();
    } else {
        alert("Failed to initialize");
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消