2010-01-21 87 views
3

我在Facebook上製作遊戲排行榜。我沒有使用連接,但在畫布內工作。當我嘗試從Facebook加載圖像時,它給了我下面的錯誤。加載圖片時出現策略文件錯誤facebook

SecurityError: Error #2122: Security sandbox violation: Loader.content: http://test cannot access http://profile.ak.fbcdn.net/v22941/254/15/q652310588_2173.jpg A policy file is required, but the checkPolicyFile flag was not set when this media was loaded. 

這裏是我的裝載代碼

public var preLoader:Loader; 
    preLoader=new Loader(); 
     **update** 
     Security.loadPolicyFile('http://api.facebook.com/crossdomain.xml'); 
     Security.allowDomain('http://profile.ak.fbcdn.net'); 
     Security.allowInsecureDomain('http://profile.ak.fbcdn.net'); 
        **update-end** 


     public function imageContainer(Imagewidth:Number,Imageheight:Number,url:String,path:String) { 
     preLoader=new Loader(); 

     Security.loadPolicyFile("http://api.facebook.com/crossdomain.xml"); 
     var context:LoaderContext = new LoaderContext(); 
     context.checkPolicyFile = true; 
     context.applicationDomain = ApplicationDomain.currentDomain; 

     preLoader.load(new URLRequest(path),context); 

什麼想法?我正在導入正確的課程。

UPDATE: 我從不同的域說加載圖像,調用FUNC http://fahim.com圖像是從http://profile.ak.fbcdn.net/v22941/254/15/q652310588_2173.jpg東西(我已經確定的圖片是靜態的不需要Facebook登錄或任何東西,他們只是用戶公開資料圖片)

+0

如果你是從Facebook加載,那麼你爲什麼從felinefrenzy.com加載策略文件? – Amarghosh 2010-01-22 04:25:06

+0

@Amarghosh,對不起,我沒有更新那裏。在我原來的代碼中,我使用的是facebook crossdomain。我剛剛更新了。它仍然給我完全相同的錯誤。 @ sberry2A,是的,我需要更改名稱,我現在正在使用不同的網址,然後是facebook提及等等。雖然所有的變化仍然給我同樣的錯誤。 – 2010-01-22 07:06:55

+0

你確定這行嗎'context.checkPolicyFile = true;'?是原始代碼本身的一部分嗎?在所述位置的政策文件似乎沒問題。 – Amarghosh 2010-01-22 13:49:40

回答

1

得到它的工作,對圖像Facebook的政策文件是在其他地方都被我拒絕一切以「*」

感謝大家的幫助。

Security.loadPolicyFile('https://fbcdn-profile-a.akamaihd.net/crossdomain.xml');

+1

什麼是Facebook政策文件的圖像的網址? – 2011-05-08 10:57:27

3
var loaderContext:LoaderContext; 
loaderContext= new LoaderContext(); 
loaderContext.securityDomain=SecurityDomain.currentDomain; 
loaderContext.checkPolicyFile = true; 

..then通的LoaderContext調用load()

9

這是URL到圖像策略文件時:

Security.loadPolicyFile('https://fbcdn-profile-a.akamaihd.net/crossdomain.xml'); 

這條線就可以工作得很好。

+4

你在聚會上一定很有趣。 – 2012-03-29 09:16:37

1

如果你只是想顯示任何圖像,而沒有得到它的數據一個很好的解決方法是不試圖使用這些數據。在這種情況下,您不需要允許安全性和跨域文件。只使用一個簡單的加載代碼:

backgroundLoader.unload(); 
backgroundLoader.contentLoaderInfo.addEventListener(Event.INIT,backgroundImageLoaded, false, 0, true); 

var lc : LoaderContext = new LoaderContext(); 
lc.checkPolicyFile = false; 
backgroundLoader.load(new URLRequest(imagePath_),lc); 

其中backgroundLoader是Loader類型的類變量。然後,當它涉及到使用圖像將其添加到您的帆布上,不請求數據(不使用e.currentTarget.content),只顯示圖像:

function backgroundImageLoaded(e:Event) : void { 
    myMovieClip.addChild(backgroundLoader); 
} 

(解決方案從http://www.onegiantmedia.com/as3--load-a-remote-image-from-any-url--domain-with-no-stupid-security-sandbox-errors