ExternalInterface not working in IE

不羁岁月 提交于 2019-12-06 13:39:01

问题


I am trying to call an action in a flash object from the javascript:

as:

function testExternalConnection(str:String):Void {
    _root.debug.htmlText = "testExternalConnection ok";
}
ExternalInterface.addCallback("testExternalConnection", this, testExternalConnection);

js:

var movie = getFlashMovie("ap1_mod_hidden")
movie.testExternalConnection();

with

function getFlashMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

I'm including my flash using swfobject:

<span id="ap1_mod_hidden"></span>
<script type="text/javascript">
    // Setting up the flash player
    var flashvars = {
        mp3Path: "stop",
        artistName : "",
        trackName : ""
    };
    var params = {
        codebase: 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
        src: '/flash/ap1_mod.swf',
        quality: 'high',
        pluginspage: 'http://www.macromedia.com/go/getflashplayer',
        scale: 'showall',
        devicefont: 'false',
        bgcolor: '#999999',
        name: 'ap1_mod',
        menu: 'true',
        id: 'mod',
        allowFullScreen: 'false',
        allowScriptAccess:'always', //sameDomain
        movie: '/flash/ap1_mod.swf',
    wmode: "transparent",
    allowfullscreen: "true"
    };

    swfobject.embedSWF("/flash/ap1_mod.swf", "ap1_mod_hidden", "300", "300", "9.0.0", false, flashvars, params);
</script>

Nothing crazy here. So this code is working fine in everything but not in Internet Explorer (what a surprise :\ ). It is getting the movie object correctly but it is not able to call the externalinterface function. It's saying that the property is not defined.

I've looked on google and SO with no success... any help would be appreciated!


回答1:


I believe you want to use the id, not the div you're adding the swf too so:

function getFlashMovie(movieName) {
    return swfobject.getObjectById("mod");
}

since you're setting "mod" as the id.



来源:https://stackoverflow.com/questions/1166079/externalinterface-not-working-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!