swf 文件可以使用 'ExternalInterface.call()' 函数为 javascript 初始化自身
can swf file initialize itself for javascript with `ExternalInterface.call()` function?
在我的代码中有初始化函数
.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()
中的第二个参数?
类似的东西
在 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 网桥已打开?
你可以通过objectID
:
ExternalInterface.call("GetSoundsObj", ExternalInterface.objectID);
.JS:
var SoundsObj = null;
function GetSoundsObj(swfId){
SoundsObj = document.getElementById(swfId);
alert(SoundsObj.SndPlay);
}
请注意,您应该在<embed>
标签和id
上设置 name
属性,或者只使用 <object>
标签。
相关文章:
- 从函数JavaScript返回不可变数组/对象
- 将对象传递给函数.JavaScript
- 如何定义const函数javascript(语法糖)
- 新的日期函数javascript
- TypeError:this.getAttribute不是一个函数-javascript
- 从函数javascript发送变量
- 扩展自容器函数Javascript
- 从内部函数javascript内部分配外部函数的对象
- 使用函数JavaScript中的函数
- 在这里使用回调函数(JavaScript)有什么好处吗
- 来自函数 Javascript 的 NaN 返回值 ||函数执行顺序
- 将“e”传递给一个新函数 - javascript
- 调用函数中的一个函数——Javascript
- 传递的变量不适用于我的函数-Javascript
- 如何将类方法设置为等于多个函数?-Javascript
- 显示php中的函数javascript
- 如何使用php代码创建函数Javascript弹出框
- 未调用的外部函数-javascript
- 如何在类中运行函数.Javascript
- 关闭mouseover上的一个函数——Javascript,jQuery