반응형
listTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Panel width="250" height="200" layout="absolute" horizontalCenter="0" verticalCenter="0">
<mx:List horizontalCenter="0" verticalCenter="-20" dataProvider="{fruit}" id="li" allowMultipleSelection="true" height="100"></mx:List>
<mx:Button x="82" y="128" label="click me" click="choice()"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var fruit:ArrayCollection = new ArrayCollection([
{label:"banana", data:0}, {label:"peach", data:1},
{label:"strawberry", data:2}, {label:"orange", data:3}]);
private function choice():void{
var str:String="";
for(var i:int=li.selectedItems.length-1;i>-1;i--){
str+=li.selectedItems[i].label+"\n";
}
mx.controls.Alert.show(str);
}
]]>
</mx:Script>
</mx:Application>
반응형