日期:2014-05-16  浏览次数:20380 次

【很急】关于JS与AS3在火狐交互的诡异问题【很急】
IE正常,火狐无论怎么试就是错误: thisMovie("swf_").MaiyunTools_PlaySound is not a function

AS3代码:

JScript code
import flash.media.Sound;
import flash.net.URLRequest;
import flash.external.ExternalInterface;

ExternalInterface.addCallback("MaiyunTools_PlaySound",PlaySound);

function PlaySound(url:String):void
{
    var s = new Sound(new URLRequest(url));
    s.play();
}


HTML代码:

HTML code
<object height="1" width="1" id="swf_" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="swf.swf" name="movie"><param value="always" name="allowScriptAccess"><embed height="1" width="1" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" name="swf_" type="application/x-shockwave-flash" src="swf.swf"></object>


JS调用方法试了NNN种,却只有IE次次成功,火狐始终不行。

以下几种都试了:

JScript code

function thisMovie(movieName)
{
    if (window.document[movieName])
    {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft")==-1)
    {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName];
    }
    else// if (navigator.appName.indexOf("Microsoft Internet")!=-1)
    {
        return document.getElementById(movieName);
    }
}
thisMovie("swf_").MaiyunTools_PlaySound("http://armmanagement.ca/flash/music/music1.mp3");


JScript code
document.getElementById("swf_").MaiyunTools_PlaySound("http://armmanagement.ca/flash/music/music1.mp3");


JScript code
document.getElementByName("swf_").MaiyunTools_PlaySound("http://armmanagement.ca/flash/music/music1.mp3");


JScript code
document["swf_"].MaiyunTools_PlaySound("http://armmanagement.ca/flash/music/music1.mp3");


JScript code
window.document.swf_.MaiyunTools_PlaySound("http://armmanagement.ca/flash/music/music1.mp3");


编译器是Flash CS4,感谢各位高人

------解决方案--------------------
没有做兼容ff的协议你有兼容ie的比如 if (navigator.appName.indexOf("Microsoft Internet")!=-1)
ff下比如
if(document.implementation && document.implementation.createDocument)//协议
------解决方案--------------------
你的html 能正常插入一个swf 文件吗???
------解决方案--------------------
你有没有在html页上做一个按钮,来触发,,还是直接就执行了??