js、as相互调用
来源:互联网 发布:婚礼海报设计软件 编辑:程序博客网 时间:2024/06/06 17:15
js调用as
在flex中进行注册
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
public var sound:Sound;
protected function play(url:String,stop:String,go:String):void // 调用函数
{
//"http://192.168.10.104:8080/group1/M00/00/00/wKgKaVFx-8m6PEtTAEjMrhpBa1U552.mp3"
var req:URLRequest = new URLRequest(url);
var context:SoundLoaderContext = new SoundLoaderContext(1000, true);
sound = new Sound(req,context);
sound.addEventListener(Event.COMPLETE,playSound);
}
public function playSound(e:Event):void{
sound.play();
}
protected function initApp(event:FlexEvent):void
{
ExternalInterface.addCallback("play",play); // 注册
}
]]>
</fx:Script>
js中调用该注册函数
function playVoice(url,stop,go){
var flash = frame.window.document.getElementById("voicePlay");
flash.play(url,stop,go);
}
as调用js
as处
protected function initApp(event:FlexEvent):void
{
var url:String = ExternalInterface.call("getUrl"); //调用
ecgService.url = url;
ecgService.send();
ecg = new Ecg(new Array(),0,0);
}
js处
<script type="text/javascript">
function getUrl(){
<% StringBuffer url = request.getRequestURL();
String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append(request.getContextPath()).append("/").toString();
%> //JSP代码
var url = "<%=tempContextUrl+"lastEcg.action"%>";
return url;
}
</script>
若用iframe内嵌则
var flash = frame.window.document.getElementById("appName"); frame为内嵌frame的名字
var parent = window.parent
- <param name='allowScriptAccess' value ='always' />
- flash不能隐藏(display:none)
- 等被调用方初始化完成再去调用,as中可以用ExtercalInterface.call('flashready')来告知初始化完成
- 跨域执行,必须在flash中设置Secure.allowDomain或者Secure.allowInsecureDomain
- js、as相互调用
- AS与JS的相互调用
- AS与JS的相互调用
- AS与JS的相互调用
- AS与JS的相互调用
- AS与JS相互通信(Flex中调用js函数)
- AS与JS相互通信(Flex中调用js函数)
- AS与JS相互通信(Flex中调用js函数)
- AS与JS相互通信(Flex中调用js函数)
- AS与JS相互通信
- as与js相互通信(flex中调用js函数)
- js调用as代码
- js调用as函数
- 页面嵌入Flex时,JS和AS相互调用(普通嵌入)
- Flex在IFrame组件之下JS和as的相互调用
- PHP----JS相互调用
- Javascript和AS相互交互调用
- as与C#的相互调用
- Intent Flag详解
- Asp.Net 代码审查
- Mysql 表记录删除后数据恢复成功
- C语言判断一个文件是否存在,以及如何删除
- 学科前沿技术(《第31次中国互联网络发展状况统计报告 》)
- js、as相互调用
- HP450安装Ubuntu解决黑屏的方法
- linux 系统软件包的安装与卸载
- android ListView下拉刷新上拉加载更多
- Sum Root to Leaf Numbers
- ECshop模板制作教程100问
- ubuntu 下terminal快捷方式大全
- java面试题经典20例
- cocos2d-x 播放序列动画的两种方法