代码之家  ›  专栏  ›  技术社区  ›  tpae

用httpService填充arraycollection

  •  0
  • tpae  · 技术社区  · 17 年前

    我正在基于数据创建RSS源应用程序,我有以下功能:

    我有一个预先填充了数据的ArrayCollection。我正在对arraycollection进行排序,获取1个数据(condition),需要连接到返回标题的RSS源,然后将arraycollection设置为与condition->标题相对应。

            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);
            }
    

    基本上,我想遍历list-arraycollection,并更新list.getitemat(i).title和从httpservice传递的结果。

    这不管用!救命!

    1 回复  |  直到 17 年前
        1
  •  0
  •   Rahul Garg    17 年前

    首先在httpService上生成一个结果事件,因为只有您才能访问请求的结果。

    在该方法中,您将从中获得resulteEvent,如果它以XML形式返回响应,您可以直接这样做。 lastresult.article.标题

    <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

    推荐文章