Flex代碼實現彙總:List中的itemRender用法

List中的itemRender用法
<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml"  
    xmlns:home="dbt.tangshan.view.home.*"
    creationComplete="newsComp()" borderStyle="none" 
    width="250" height="75" backgroundAlpha="0"
    horizontalScrollPolicy="off" verticalScrollPolicy="off" >
<mx:List id="lastNewsList" width="100%" height="100%" fontSize="12" borderStyle="none" backgroundAlpha="0" 
    horizontalScrollPolicy="off" verticalScrollPolicy="off" >
    <mx:itemRenderer>
        <mx:Component>
            <mx:Label text="{data}" width="100%" />
        </mx:Component>
    </mx:itemRenderer>
</mx:List>
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
private var newsRss:XML;
private var svc:HTTPService;
private function newsComp():void{
    svc = new HTTPService;
    svc.url = 'http://tangshanmap.appspot.com/getNewsXml.action';
    svc.addEventListener(ResultEvent.RESULT,onResult);
    svc.resultFormat = "e4x";
    svc.send();
}
private function onResult(event:ResultEvent):void{
    newsRss = XML(event.result);
    var title_:Array = [];
    for each(var xml:XML in newsRss.channel.item){
    title_.push(xml.title.toString());
}
lastNewsList.dataProvider = title_;
}

]]>
</mx:Script>
</mx:Box>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章