当我想在我的 Flex 项目中加载我的资产时,我收到了这个错误:
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 中的安全策略的信息,但我仍然没有弄清楚如何允许本地访问我的应用程序。