在我的代码中有初始化函数
HTML
<embed id="SoundsObj"........
JS
var SoundsObj = document.getElementById('SoundsObj');
function GetSoundsObj(){
alert(top.SoundsObj.SndPlay); //I can see it has initialized itself
}
AS3
ExternalInterface.call("GetSoundsObj");
我很奇怪是否有可能将JS中的swf对象作为ExternalInterface.call()
sunction中的第二个参数传递?
类似
in as3
ExternalInterface.call("GetSoundsObj",this); //by `this` I mean swf object
在js
var SoundsObj = null;
function GetSoundsObj(arg){
SoundsObj = arg;
alert(SoundsObj.SndPlay);
}
完全确定swf-js桥是否开启?
答案 0 :(得分:0)
您可以传递objectID
:
ExternalInterface.call("GetSoundsObj", ExternalInterface.objectID);
JS:
var SoundsObj = null;
function GetSoundsObj(swfId){
SoundsObj = document.getElementById(swfId);
alert(SoundsObj.SndPlay);
}
请注意,您应在name
代码和<embed>
上设置id
属性,或者只使用<object>
代码。