StupidBeauty
Read times:477Posted at:Mon Dec 3 05:47:12 2012
- no title specified

转载 AS3 JS 之间的简单自定义参数通讯

使用ExternalInterface接口就可以在Action Script 3和javascript之间通信。

http://as3.aa-a.net/as3-js-parameters-transfer.html?jdfwkey=jdlyp3

亮点:

使用外部通信接口ExternalInterface
这也是AS2时代进化来的,目前公认的最靠谱的通信方式.
使用方法:
1.JS调用AS3的函数
确定JS调用AS3之前,要在AS3中绑定调用函数,也就是说,只有AS3答应给的方法JS才能调用.
使用:
ExternalInterface.addCallback(functionName:String, closure:Function):void 有两个参数:
functionName:String — 容器可用于调用函数的名称。
closure:Function — 要调用的 closure 函数。 这可能是一个独立的函数,或者可能是引用对象实例方法的 closure 方法。通过传递 closure 方法,回调实际上可以定向到特定对象实例的方法。

ExternalInterface.addCallback("getASVars",getASFun);
private function getASFun(value:String):void {
//得到JS传来的值:value
}

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4