2009-07-14 83 views
0

我正在創建一個基於數據的RSS提要應用程序,我有以下內容:使用HTTPService填充ArrayCollection

我有一個預先填充了數據的ArrayCollection。我通過ArrayCollection進行排序,獲取1條數據(條件),並且需要連接到一個RSS源,它將返回標題,並將我的ArrayCollection設置爲與條件 - >標題相對應。

 public function updateArrayList(list:ArrayCollection):ArrayCollection { 
      trace(list); 
      for(var i:int = 0; i < list.length; i++) { 
      // Alert.show(list.getItemAt(i).condition); 
       getRSSUpdate(list.getItemAt(i).condition); 
       list.getItemAt(i).title = getRSS.lastResult.article.title; 
      } 
      return list; 
     } 

     public function getRSSUpdate(condition:String):void { 
      getRSS = new HTTPService(); 
      getRSSParam = new Object; 
      getRSSParam.condition = condition; 
      getRSS.method = "POST"; 
      getRSS.url = "http://localhost/site/remoteRequests/flash/rss/getRSS.php"; 
      getRSS.send(getRSSParam); 
     } 

基本上,我想通過列表的ArrayCollection進行迭代,並更新list.getItemAt(i)與從結果HTTPService在通過.title僞。

這不起作用!幫幫我!

回答

0

首先在httpservice上創建結果事件,因爲只有您將訪問請求的結果。

在這種方法中,你會從取出所需的值獲得的ResultEvent如果返回響應,XML可以直接做這樣lastResult.article.title

<mx:HTTPService id="yahooHTTPService" 
    url="http://search.yahooapis.com/WebSearchService/V1/webSearch" 
    method="GET" 
    makeObjectsBindable="true" result="httpServiceResult(event)" 
    fault="httpServiceFault(event)" showBusyCursor="true"> 
</mx:HTTPService> 

這裏有一個例子http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html#193905

+0

這不是我要求的。我有一個預先填充數據的ArrayCollection。我通過ArrayCollection進行排序,獲得1條數據(條件),並且需要連接到一個RSS源,該源返回我的一點數據(標題),並且我的條件 - >標題填充了我的ArrayCollection。 – tpae 2009-07-14 16:23:10