为什么我的Flex as3 crossdomain.xml不起作用? [英] Why is my Flex as3 crossdomain.xml not working?
问题描述
我使用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跨域策略系统http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">
<跨网域政策>
< allow-access-from domain =*/>
< allow-http-request-headers-from domain =*headers =*/>
< / cross-domain-policy>
<2>
<?xml version =1.0?>
<!DOCTYPE跨域策略系统http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">
<跨网域政策>
< allow-http-request-headers-from domain =*headers =*secure =false/>
< / cross-domain-policy>
<3>
<?xml version =1.0?>
<!DOCTYPE跨域策略系统http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">
<跨网域政策>
< allow-access-from domain =*/>
< / cross-domain-policy>
这是我在Flashlog文件中得到的错误。
*** Security Sandbox Violation ***
SecurityDomain'http:// localhost:81 / controller / view'试图访问不兼容的
上下文'http://mydomain.blob.core.windows.net/crossdomain.xml'
任何帮助将不胜感激。这个问题让我疯狂。提前致谢。
所以我想清楚我做错了什么。你需要发送一个LoaderContext的bulkLoader,就像你对普通的Loader类一样。这是我用过的代码。加载声音文件时也使用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();
I have spent so much time trying to figure out what is going wrong with my crossdomain.xml implementation. There are tons of questions here about them and I have tried everything from every question.
I am using Azure Blob Storage to store images that my swf needs to access. Also I am using the BulkLoader swc to load in these assets. Below is code that runs before the application attempts to load images from the 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");
Here is a sample of different crossdomain.xml configurations I have tried. I've probably tried 20 different configurations and nothing seems to work.
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>
This is the error I get in the flashlog file.
*** Security Sandbox Violation ***
SecurityDomain 'http://localhost:81/controller/view' tried to access incompatible
context 'http://mydomain.blob.core.windows.net/crossdomain.xml'
Any help would be appreciated. This problem is driving me crazy. Thanks in advance.
So I figured out what I was doing wrong. You need to send bulkLoader a LoaderContext just like you do to the normal Loader class. Here is the code I've used. Also use a SoundLoaderContext when loading a sound file.
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();
这篇关于为什么我的Flex as3 crossdomain.xml不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!