2012-03-19 61 views
0

*安全沙箱冲突*动作callback()函数 - 的URLRequest()导致 “安全沙箱冲突”

的SecurityDomain 'http://loadimage.my.com' 试图访问不兼容的情况下的“http ://my.com/My.swf'

我正在加载一个jpg图像文件在actionscript中。

在回调函数中,我想要addChild,但会显示“Security Sandbox Violation”。

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> 
+0

'image'的类型是什么? (例如'slide'是一个'Slide') – Manish 2012-03-19 19:38:52

回答

0

我不知道你想为image代码里面做什么,但我的猜测是,你正在试图访问装载机的内容,这显然是一种违反安全自SWF正在从不同的域加载。

有访问已经从不同的域加载的SWF的内容有两种方式:

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

更多细节在这里:

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