특별한딸기이야기
listbox 본문
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function onChange() : void
{
var msg : String;
msg = "selectedIndex - " + String(lstFruits.selectedIndex) + "\n";
msg += "selectedItem.Code - " + String(lstFruits.selectedItem.code) + "\n";
msg += "selectedItem.Label - " + String(lstFruits.selectedItem.label);
Alert.show(msg);
}
]]>
</mx:Script>
<mx:Array id="fruit">
<mx:Object label="사과" code="55" />
<mx:Object label="배" code="66" />
<mx:Object label="복숭아" code="77" />
<mx:Object label="감" code="88" />
<mx:Object label="자두" code="99" />
</mx:Array>
<mx:List x="100" y="100" width="200" height="100" id="lstFruits" dataProvider="{fruit}" fontSize="12" change="onChange()" />
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function onChange() : void
{
var msg : String;
msg = "selectedIndex - " + String(lstFruits.selectedIndex) + "\n";
msg += "selectedItem.Code - " + String(lstFruits.selectedItem.code) + "\n";
msg += "selectedItem.Label - " + String(lstFruits.selectedItem.label);
Alert.show(msg);
}
]]>
</mx:Script>
<mx:Array id="fruit">
<mx:Object label="사과" code="55" />
<mx:Object label="배" code="66" />
<mx:Object label="복숭아" code="77" />
<mx:Object label="감" code="88" />
<mx:Object label="자두" code="99" />
</mx:Array>
<mx:List x="100" y="100" width="200" height="100" id="lstFruits" dataProvider="{fruit}" fontSize="12" change="onChange()" />
</mx:Application>