flex中combobox绑定xml数据后取不到data
问题如题,代码如下
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
[Bindable]
private var xml:XML = <root>
<item name="datagrid" data="1"/>
<item name="combobox" data="2"/>
<item name="List" data="3"/>
</root>;
[Bindable]
private var xmlLc:XMLListCollection;
[Bindable]
private var arrC:ArrayCollection;
private function init():void
{
xmlLc = new XMLListCollection(xml.children());
arrC = new ArrayCollection();
arrC.addItem({label:"aa",data:"1"});
arrC.addItem({label:"bb",data:"2"});
arrC.addItem({label:"cc",data:"3"});
}
private function show():void
{
trace(cb.value);
trace(cb.selectedItem.data);
trace("111");
}
]]>
</mx:Script>
<mx:ComboBox id="cb" x="196" y="263" editable="false" dataProvider="{xml.item}" labelField="@name" change="show()"></mx:ComboBox>
</mx:WindowedApplication>