* 违反安全沙盒 *
SecurityDomain 'http://loadimage.my.com' 试图访问不兼容的上下文 'http://my.com/My.swf'
我在 actionscript 中加载一个 jpg 图像文件。
在回调函数中我想添加Child,但显示“安全沙箱违规”。
public function preloadAll() {
...
// call preLoad with callback function
preLoad(function (slide:Slide):void{
//
// loading this url causes the error *** Security Sandbox Violation ***
//
var url:String = "http://my.com/My.swf";
var urlReq:URLRequest = new URLRequest(url);
var loader:Loader = new Loader()
loader.load(urlReq);
slide.image.addChild(loader);
});
...
}
public function preLoad(callback: Function = null) : void {
this.url = "http://image.my.com/cache/Picture_001.jpg"
var self:Slide = this;
this.image.addEventListener(Event.COMPLETE, function() : void {
// callback when image completes loading
callback(self);
});
this.image.load(this.url);
}
http://my.com/crossdomain.xml
<?xml version="1.0" ?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*"/>
<allow-access-from domain="" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>