我正在使用 swf 对象嵌入 swf。我正在尝试使用外部接口从 JS 调用 flash 函数,但遇到了麻烦。我搜索了所有文档,阅读了大量内容,我确信我做对了。谁能指出问题可能出在哪里?
var flashvars = {};
var params = {wmode:"opaque", allowscriptaccess:"always" };
var attributes = {id:"MySwf", name:"MySwf"};
swfobject.embedSWF("MySwf.swf", "flashContent", "600", "400", "9.0.0", "swfs/expressInstall.swf", flashvars, params, attributes,function(e){
if(e.success){
_flashRef = e.ref;
testExternalInterface();
}else{
alert("We are sorry, flash is required to view this content.");
}
});
function testExternalInterface(){
var swf = document.getElementById("MySwf");
swf.sendMeTheGoods("TEST TEST");
};
以上是我flash中的嵌入代码和js函数
if (ExternalInterface.available)
{
trace("adding external interface");
ExternalInterface.addCallback("sendMeTheGoods", sendMeTheGoods);
}
public function sendMeTheGoods(text:String):void
{
trace("setting vars")
trace(text);
txtYouSent.text = text;
}
我收到错误 Uncaught TypeError: Object # has no method 'sendMeTheGoods'
我已经尝试过引用 document.getElementById("MySwf"); 和 document.getElementById("flashContent"); 我得到了两种方式的错误。有什么建议么?