首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的Flex as3 crossdomain.xml不能工作?

为什么我的Flex as3 crossdomain.xml不能工作?
EN

Stack Overflow用户
提问于 2014-10-31 13:40:11
回答 1查看 199关注 0票数 0

我花了那么多时间试图找出我的crossdomain.xml实现出了什么问题。这里有很多关于他们的问题,我从每一个问题都试过了。

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

代码语言:javascript
复制
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.

代码语言:javascript
复制
<?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.

代码语言:javascript
复制
<?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.

代码语言:javascript
复制
<?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>

这是我在闪存日志文件中得到的错误。

代码语言:javascript
复制
*** Security Sandbox Violation ***
SecurityDomain 'http://localhost:81/controller/view' tried to access incompatible
context 'http://mydomain.blob.core.windows.net/crossdomain.xml'

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-01 01:05:22

所以我想出了我做错了什么。您需要向bulkLoader发送一个LoaderContext,就像对普通Loader类所做的那样。这是我用过的代码。在加载声音文件时也要使用SoundLoaderContext。

代码语言:javascript
复制
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();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26676092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档