2012-03-13 48 views
0

嘗試從登錄的Facebook用戶的朋友列表中加載配置文件圖像到as3畫布應用程序時,我收到了一個神祕的結果。在幾乎每一個(非Facebook的)應用程序,我已經取得了其中加載圖像,需要我用如下:AS3,Facebook API - 在圖像加載後無法從事件對象檢索圖像

private function loadPic():void 
{ 
    var url:String = Facebook.getImageUrl(_friendslistObjectArray[_loadCount].id); 
    _picLoader = new Loader(); 
    var req:URLRequest = new URLRequest(url); 
    _picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPicLoaded); 

    _picLoader.load(req); 
} 

private function onPicLoaded(evt:Event):void 
{ 
    _picLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onPicLoaded); 

    // grab image from loader event to use it  
    var image = evt.target.content; 

    trace("this trace won't even show up and the program silently fails unless the line above this is removed"); 

    _loadCount++; 
    loadPic(); 
} 

我無法從事件對象檢索圖像,而我給根本沒有錯誤。這一切都只是失敗而已。如果我刪除了行var image = evt.target.content,該過程將貫穿整個數組。

我想不出任何原因會發生。此外,如果我查看螢火蟲的淨活動,只要我沒有提到我剛纔提到的那條線,我就會看到圖像被加載。我似乎無法從事件對象獲取圖像數據以將其添加到舞臺或容器動畫片段。

這應該很容易。我在這裏試圖弄清楚我錯過了什麼或錯在哪裏。有什麼想法嗎?謝謝!

回答

0

找到了答案:

這條線:

Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml"); 

前右_picLoader.load(REQ)放置;解決了這個問題。

這是一個跨域錯誤,但由於某些未知原因,錯誤沒有報告,直到我投擲了var image = evt.target.content;放入try/catch並讀取錯誤消息。

道具這個職位的答案: Load profile image from Facebook with Actionscript 3

0

evt.target應該是一個LoaderInfo對象,在這裏嘗試代碼:

var image = (evt.targe as LoaderInfo).loader.content;