0

我在将命令从 javascript 传递到 flash 时遇到一些问题。我的代码终于可以在 IE 和 Chrome 中运行了。可悲的是它没有做任何我Firefox。知道为什么吗?

提前致谢!

JAVASCRIPT

<script type="text/javascript">

    //function setCurrentPage(newPage) {
    //    currentPage = newPage;
    //    SendDataToFlashMovie(newPage);
    //}
    function getFlashMovieObject(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{

            return document.getElementById(movieName);

    }
    }
    function SendDataToFlashMovie(newPage){
    var flashMovie=getFlashMovieObject("java");
    flashMovie.callAs(newPage);
    }

</script>

<a href="#" onClick="SendDataToFlashMovie('Home')">Home</a>

闪光

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="java" align="middle">
<param name="movie" value="java.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="always" />

<!--[if !IE]>-->
<object id="java" type="application/x-shockwave-flash" data="java.swf" width="550" height="400">
<param name="movie" value="java.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="always" />
<EMBED src="java.swf" quality="high" swliveconnect="true" width="550" height="400" name="java" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">
</EMBED>
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
        <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>
4

1 回答 1

2

使用SWFObject嵌入您的 Flash 文件(有一个方便的代码生成器- 使用“动态发布”)。

然后 JS 代码将如下所示:

<script type="text/javascript">
    function SendDataToFlashMovie(newPage){
        var flashMovie = document.getElementById("java");
        flashMovie.callAs(newPage);
    }
</script>

<a href="#" onClick="SendDataToFlashMovie('Home')">Home</a>
于 2012-07-04T12:23:48.293 回答