AS与JS相互通信(Flex中调用js函数)

AS与JS相互通信(Flex中调用js函数)
【转自: http://www.blogjava.net/Alpha/archive/2009/06/27/284373.html
Flex中As调用Js的方法是:

     1、导入包 (import flash.external.ExternalInterface;)
     2、使用ExternalInterface.call("Js函数名称",参数)进行调用,其返回的值就是Js函数所返回的值
 
Js调用As的方法是:
     1、导入包 (import flash.external.ExternalInterface;)
     2、在initApp中使用ExternalInterface.addCallback("用于Js调用的函数名",As中的函数名)进行注册下
     3、js中 就可以用document.getElementById("Flas在Html中的ID").注册时设置的函数名(参数)进行调用

你可能感兴趣的:(AS与JS相互通信(Flex中调用js函数))