问题描述:写了一个js与as的通信

as中通过此方法来注册js的回调

if(ExternalInterface.available){

try{

ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript);


}catch(error:SecurityError){


}catch(error:Error){


}

}else{


}

 

firefox中通过swf = swfobject.getObjectById("WebcamFaceDetector");获取到flash对象

通过下面方法调用:

if (swf && swf.sendToActionScript)

{

try

{

swf.sendToActionScript(eventName, data);

}

catch(ex){}

}

通过firedebug调试swf和swf.sendToActionScript都是定义了的。

但是flash中总是收不到回调。在crome和IE中测试flash可以收到回调。

 

通过查看多个论坛帖子,终于解决此问题

问题解决了,报那个错误是因为默认actionscript中不允许向将方法注册到不同域的 html文档中, 对于这个需要在as中加一下代码即可解决:


import flash.system.Security;

Security.allowDomain("*");

Security.allowInsecureDomain("*");

 

希望对大家有帮助