2011-03-08 87 views
1

我正在做一個Facebook應用程序,我想從用戶的相冊中提取所有可能的圖像。從Flash Builder中的Facebook加載圖像

我現在想要做的是一個fql查詢,以便我可以找到屬於該特定用戶的所有圖像。它是這樣的:

 protected function loadFromFacebook(event:MouseEvent):void { 

      var fql:String = "select src_small from photo where owner = me()";    
      Facebook.fqlQuery(fql, handleGetPhotosResponse); 

     } 


     private function handleGetPhotosResponse(event:Object, fail:Object):void { 
      if (event != null){ 

       facebookPhotos = new ArrayCollection(event as Array); 

      } 
     } 

我將這個圖像存儲在數組集合,但我不知道如何處理之後。我如何將這些圖像加載到瓦片列表或加載程序中?

任何幫助將不勝感激,

感謝

回答

0

假設你有一個名爲「TLIST」一個TileList組件,你會做一個「for循環」上的ArrayCollection,並創建一個新的形象,並添加它在每次迭代時都返回到TileList。

// I am not sure if the array collection contains photo urls, 
// but this is the general idea ... 
// you may need to build the url with fb graph ... 
for (var i:uing = 0; i < facebookPhotos.length; i++) 
{ 
    var img:Image = new Image(); 
    img.load(facebookPhotos.getItemAt(i)); // url here 
    tList.addChild(img); 
} 
0

你應該做一個處理函數來接收一個結果對象和一個失敗對象。 結果對象是您使用fql請求的字段數組。

protected function loadFromFacebook(event:MouseEvent):void { 

     var fql:String = "select src_small from photo where owner = me()";    
     Facebook.fqlQuery(fql, handleGetPhotosResponse); 

    } 

    protected function handleGetPhotosResponse(result:Object, fail:Object):void 
     { 
      photosList = new ArrayCollection(); 
      var photo:Object; 
      for (var i:Object in result) 
      { 
       photo = new Object(); 
       photo.imgSrc = result[i].src_small; 
       photosList.addItem(photo); 
      } 
      provider = photosList; 
     }