【发布时间】:2010-11-17 13:08:02
【问题描述】:
我正在尝试将放置在 Amazon S3 (b.com) 上的 swf 加载到不同域 (a.com) 上的 swf 中,它会引发此错误
SecurityError: Error #2121: Security sandbox violation: Loader.content:http://www.a.com/loader.swf cannot accesshttp://b.com/loadee.swf. This may be worked around by calling Security.allowDomain.
at flash.display::Loader/get content()
a.com 和 b.com 在它们的根目录上都有一个 crossdomain.xml,看起来像
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
我尝试加载的 swf (b.com/loadee.swf) 是由软件生成的,因此我无法向其添加 Security.allowDomain("*") 或类似内容。
我可以通过某种方式加载这个 swf,还是我坚持使用 a.com 来托管所有内容?我还希望 loader.swf 和 loadee.swf 能够通信(传递变量并进行函数调用) 如果可能的话。这就是我在 loader.swf 中的内容
Security.allowDomain("*");
Security.allowInsecureDomain("*");
Security.loadPolicyFile("http://b.com/crossdomain.xml");
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.checkPolicyFile = true;
loaderContext.allowCodeImport = true;
var loader:Loader = new Loader();
loader.load(new URLRequest("http://b.com/loadee.swf"), loaderContext);
如果有人有任何想法,我将不胜感激。
【问题讨论】:
标签: flash actionscript-3 security sandbox