0

* 违反安全沙盒 *

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>
4

1 回答 1

0

我不确定您在代码中到底要做什么image,但我的猜测是您正在尝试访问加载程序的内容,这显然违反了安全性,因为 SWF 是从不同的域加载的。

有两种方法可以访问从不同域加载的 SWF 内容:

  1. 在“当前”安全域中加载 SWF
  2. Security.allowDomain()在加载的 SWF 中使用

更多细节在这里:

https://stackoverflow.com/a/9547996/579230

于 2012-03-19T19:46:38.527 回答