当我想要加载我的Flex项目在我的资产,我得到这个错误:的SecurityError:错误#2142:安全沙箱冲突
SecurityError: Error #2142: Security sandbox violation: local SWF files
cannot use the LoaderContext.securityDomain property.
app:/Main.swf was attempting to load app:/assets/stories/bear.swf.
我创建一个LoaderContext并将其分配到的SWFLoader但我仍然得到这个错误。这里是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:ns1="*"
applicationDPI="240" creationComplete="initApp(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import flash.system.SecurityDomain;
import flash.system.ApplicationDomain;
protected function initApp(event:FlexEvent):void
{
var context:LoaderContext = new LoaderContext();
context.securityDomain = SecurityDomain.currentDomain;
context.applicationDomain = new ApplicationDomain();
Story.loaderContext = context;
Story.source = "app:/assets/stories/Bear1.swf";
}
]]>
</fx:Script>
<s:SWFLoader id="Story" left="0" right="0" top="0" bottom="0"
trustContent="true"
scaleContent="true"/>
</s:Application>
我Flex中读了很多关于安全策略,但我还是没弄明白我怎样才能让我的应用程序的本地访问。
这个问题没有妥善解决。但由技巧你摆脱这.. – Devendra
@dev我可以使用@嵌入,但恐怕最后的SWF需要更长的时间来加载,特别是我的资产非常大。 – bman
你试过swfloader? – Devendra