解决SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller的异常问题

 前面用Ant build出来flex application的flash文件,但直接在嵌入html中,如果本地访问的化,则会弹出错误窗口,报告:

 

SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///D:/WorkDir/EOS Projects/bps/v6.1/doc/BPS61/doc/04_Requirement/draft/BPS_UI/build/flowdesigner3.swf cannot access file:///D:/WorkDir/EOS Projects/bps/v6.1/doc/BPS61/doc/04_Requirement/draft/BPS_UI/build/flowdesigner3.html. at flash.external::ExternalInterface$/_initJS() at flash.external::ExternalInterface$/addCallback() at flowdesigner3/appComplete() at flowdesigner3/___flowdesigner3_Application1_applicationComplete()

 

这样的异常问题,是本地没有声明可以访问js的权限问题,可以在html中引入swf文件的时候,设置其可以访问script。如下:即“allowscriptaccess”参数设置为“always”:(以下代码是采用的swfobject这个组件)

 

<mce:script type="text/javascript" src="swfobject.js" mce_src="swfobject.js"></mce:script> <mce:script type="text/javascript"><!-- var flashvars = {}; var params = { allowscriptaccess : "always" }; var attributes = { id : "flowdesigner" }; swfobject.embedSWF("flowdesigner3.swf", "myContent", "100%", "100%", "9.0.0", "expressInstall.swf",flashvars,params,attributes); // --></mce:script>

 

如过是使用object tag的化,则如下:

<param name="allowScriptAccess" value=“always" />

 

你可能感兴趣的:(html,Security,File,application,attributes,sandbox)