Flash / Javascript通信错误

时间:2010-04-15 13:54:19

标签: flash actionscript-3

我正在使用以下代码。它适用于getElementByID,但如果我使用操作系统检测功能,它就会停止工作。

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

getFlashMovie('myId').sendToActionsript(str);

上面的代码不起作用,而下面的代码正在处理任何想法?

document.getElementById('myId').sendToActionscript(str);

编辑:同一件事的另一段代码,它也不起作用。

        function getFlashMovieSecond(movieName)
        {
                    if (window.document[movieName])
                    {
                        return window.document[movieName];
                    }
                    if (navigator.appName.indexOf("Microsoft Internet")==-1)
                    {
                        if (document.embeds && document.embeds[movieName])
                            return document.embeds[movieName];
                    }
                    else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
                    {
                        return document.getElementById(movieName);
                    }

        }

1 个答案:

答案 0 :(得分:0)

这似乎有效

 function thisMovie(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {

                    return window[movieName];

    } else {

                    return document[movieName];

    }

}