作家
登录

flash javascript之间的通讯方法小结

作者: 来源:www.28hudong.com 2013-03-30 02:47:53 阅读 我要评论

不用getURL和fsCommand方法 flash使用的actionscript跟javascript是非常相通的,下面描述如何互相调用函数: 1:javascript调用flash中的函数 在flash的脚本中增加 import flash.external.ExternalInterface; 假定要调用的函数是hello,as代码如下 function hello(){ return "hello"; } ExternalInterface.addCallback("hello", this, hello); //第一个参数为导出函数名,第三个参数为as的函数名,这样就可以在js中调用as的hello函数了 2:flash调用js的函数 ExternalInterface.call("hello2", "jacky"); //第一个参数是js的函数名,后面的是js函数的参数 3:如何互相调用 html代码如下: <object type="application/x-shockwave-flash" data="test.swf" width="525" height="390" name="test"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="test.swf" /> <param name="quality" value="high" /> <param name="scale" value="noScale" /> <param name="wmode" value="transparent" /> </object> javascript代码如下: function callFromFlash() { var a=thisMovie("test").hello(); alert(a); } function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName] } else { return document[movieName] } } //注意,不能使用document.getElementById此类函数取得网页中的flash对象,只能使用thisMovie函数中的代码 国外看到的另一种方法: You can't call a function, but you can change/set a variable and use the watch() method to execute the code whenever the value is changed. ActionScript Code: function changeType(prop, oldval, newval) { //do your stuff return newval; } var strType = ""; this.watch("strType", changeType);

  推荐阅读

  用tip解决Ext列宽度不够的问题

渲染的函数写成如下: function renderHallName(value, meta, rec, rowIdx, colIdx, ds){ return '<div ext:qtitle="" ext:qtip="' + value + '">'+ value +'</div>'; } 顶部需要加入Ext.QuickTips.init(); qtitle>>>详细阅读


本文标题:flash javascript之间的通讯方法小结

地址:http://www.17bianji.com/kaifa2/JS/29110.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)