list组件
<?xml version="1.0"?> <!-- Simple example to demonstrate the Spark List component --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.messaging.AbstractConsumer; import spark.events.IndexChangeEvent; import mx.collections.ArrayCollection; [Bindable] private var array:ArrayCollection = new ArrayCollection([{id:1,city:"北京"},{id:2,city:"天津"},{id:3,city:"上海"}]); protected function list1_changeHandler(event:IndexChangeEvent):void { Alert.show(list1.selectedItem.city); } ]]> </fx:Script> <s:VGroup left="20" right="20" top="20" bottom="20"> <s:List id="list1" dataProvider="{array}" labelField="city" x="87" y="101" width="144" change="list1_changeHandler(event)"> <s:itemRenderer> <fx:Component> <s:ItemRenderer> <fx:Script> <![CDATA[ import mx.controls.Text; override public function set data(value:Object):void { sn.text = String(itemIndex+1); txt.text = String(value.city); but.label = String(itemIndex+1); } ]]> </fx:Script> <s:Label id="sn" x="0" /> <s:Label id="txt" x="30" /> <s:Button id="but" width="45" x="90"/> </s:ItemRenderer> </fx:Component> </s:itemRenderer> </s:List> </s:VGroup> </s:Application>