2012-03-19 38 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