js如何调用flash函数

js如何调用flash函数,第1张

flash调用js最简单的方法是:getURL(javascript:function())//function为此FLASH所在页面的JS函数名.js传递变量给flash最简单的方法是:flash.setVariable(变量名,变量值)//flash为此FLASH的id

使用flash.external.ExternalInterface

步骤一:flash中定义可以访问的函数hello

flash as文件中的关键代码:

import flash.external.ExternalInterface  

function hello(){  

        return "测试成功了哦~~"  

    } 

//允许js调用flash中的函数 参数1:要调用flash函数的js函数,参数2:被调用flash函数  

ExternalInterface.addCallback("helloas",hello)

步骤二:js中定义可以访问的函数hello和flash文件加载

<script type="text/javascript">  

  function hello(v)  

  {  //js中定义的测试函数

      alert(v)   

  }  

</scritp>

<body>

  //flash组件

  <object  id="test" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="" width="560" height="270"> </object>

</body>

步骤三:flash访问js中的hello方法

ExternalInterface.call("hello", "jacky")

步骤四:js访问flash的hello方法

document.getElementById("test").helloas()


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11363379.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-15
下一篇2023-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存