【问题标题】:Why is my Flex as3 crossdomain.xml not working?为什么我的 Flex as3 crossdomain.xml 不工作?
【发布时间】:2014-10-31 13:40:11
【问题描述】:

我花了很多时间试图弄清楚我的 crossdomain.xml 实现出了什么问题。这里有很多关于它们的问题,我已经尝试了每个问题的所有内容。

我正在使用 Azure Blob 存储来存储我的 swf 需要访问的图像。此外,我正在使用 BulkLoader swc 加载这些资产。下面是在应用程序尝试从 url 加载图像之前运行的代码。

Security.allowDomain("mydomain.blob.core.windows.net");
Security.allowInsecureDomain("mydomain.blob.core.windows.net");
Security.loadPolicyFile("http://mydomain.blob.core.windows.net/crossdomain.xml");

这是我尝试过的不同 crossdomain.xml 配置的示例。我可能已经尝试了 20 种不同的配置,但似乎没有任何效果。

1.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="all" />
  <allow-access-from domain="*" />
  <allow-http-request-headers-from domain="*" headers="*" />
</cross-domain-policy>

2.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="master-only" />
  <allow-access-from domain="*" secure="false" />
  <allow-http-request-headers-from domain="*" headers="*" secure="false" />
</cross-domain-policy>

3.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*"/>
</cross-domain-policy>

这是我在 flashlog 文件中遇到的错误。

*** Security Sandbox Violation ***
SecurityDomain 'http://localhost:81/controller/view' tried to access incompatible
context 'http://mydomain.blob.core.windows.net/crossdomain.xml'

任何帮助将不胜感激。这个问题快把我逼疯了。提前致谢。

【问题讨论】:

  • 只是猜测,但您能检查包含此 crossdomain.xml 文件的 $root 容器的 ACL 吗?它应该是BlobPublic
  • 是的,$root 容器设置为 Blob。我可以在浏览器中加载 crossdomain.xml。

标签: xml actionscript-3 flash apache-flex azure


【解决方案1】:

所以我发现我做错了什么。您需要像发送到普通 Loader 类一样向 bulkLoader 发送 LoaderContext。这是我使用的代码。加载声音文件时也要使用 SoundLoaderContext。

var currentSecurityDomain:SecurityDomain = null;
if (Security.sandboxType == Security.REMOTE)
    currentSecurityDomain = SecurityDomain.currentDomain;

var loaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, currentSecurityDomain);

var currentSecurityDomain:SecurityDomain = null;
if (Security.sandboxType == Security.REMOTE)
    currentSecurityDomain = SecurityDomain.currentDomain;

var soundLoaderContext = new SoundLoaderContext(1000, true);

var currentSecurityDomain:SecurityDomain = null;
if (Security.sandboxType == Security.REMOTE)
    currentSecurityDomain = SecurityDomain.currentDomain;

var loaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, currentSecurityDomain);
var soundLoaderContext = new SoundLoaderContext(1000, true);

var bulkLoader:BulkLoader = new BulkLoader("main");
bulkLoader.add(URL, { context: loaderContext, "id":animationID, maxTries:1, priority:priority});
bulkLoader.add(URL_TO_SOUND, { context: soundLoaderContext, "id":animationID, maxTries:1, priority:priority});
bulkLoader.addEventListener(BulkLoader.COMPLETE, onAllItemsLoaded);
bulkLoader.start();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-31
    • 1970-01-01
    • 1970-01-01
    • 2019-08-28
    • 2014-08-27
    • 2021-12-06
    • 2021-08-23
    相关资源
    最近更新 更多