2009-08-28 54 views
0

我想知道是否有任何解決了類似的東西。沙箱侵犯 - 在Flash Player中 - 跨域問題?

我在網站-A上有一個網站,它具有從網站B提供的嵌入式swf。 swf在通過URLLoader從站點B上的文件夾嘗試訪問txt文件時出現安全沙箱錯誤。

我在站點B上有一個跨域策略(當前設置爲)。 我在這裏錯過了什麼?我可以在哪裏放置文本文件,以便swf可以加載它? 我同時訪問網站A和B.

任何幫助非常讚賞

回答

1

這取決於你如何編譯你的SWF。有一個安全Sanbox問題。關於安全性的Essential Actionscript 3.0有一整章,但我會盡量保持簡短。

使用Flash IDE中,你有兩個「安全選項」 或者您的SWF有權加載剪輯本地(來自同一個域), 無論是從網絡(其他域)

比方說swfA是SWF現場-A和swfB是在現場-B的SWF

第一件事,嘗試一個LoaderContext設爲您用於swfB

如裝載機

//1st param(true) in LoaderContext constructor means always check for policy files 
var swfBLoaderContext:LoaderContext = new LoaderContext(true); 
var swfBLoader:Loader = new Loader(); 
swfBLoader.contentLoaderInfo.addEventListener(Event.INIT, swfBLoaded); 
swfBLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, swfBIOError); 
swfBLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, swfBSecurityError); 

swfBLoader.load(new URLRequest('http://siteb.com/b.swf',swfBLoaderContext); 

function swfBLoaded(event:Event):void{ 
    trace(event.target.content); 
} 
function swfBIOError(event:IOErrorEvent):void{ 
    trace(event); 
} 
function swfBSecurityError(event:SecurityErrorEvent):void{ 
    trace(event); 
} 

然後在您的文檔設置中更改您的本地播放安全性以訪問網絡文件。

alt text http://www.adobe.com/devnet/flash/articles/local_network_playback/fig01.jpg

感謝Adobe獲得了該圖像。

欲瞭解更多詳情請查閱this article on devnet

Goodluck。