<?xml version="1.0"
encoding="utf-8"?>
<mx:Application xmlns:mx=""
layout="absolute">
<mx:Script>
<![CDATA[
//导入数据集合类
import
mx.collections.ArrayCollection;
private var
cartArray:ArrayCollection = new ArrayCollection();
//向list里面添加内容
function
addToCart():void{
cartArray.addItem(myCombo.selectedItem.data);
}
]]>
</mx:Script>
<!--定义一个用于访问的数组-->
<mx:Array
id="coffeeArray">
<mx:Object>
<mx:label>北京</mx:label>
<mx:data>中国的首都</mx:data>
</mx:Object>
<mx:Object>
<mx:label>纽约</mx:label>
<mx:data>美国的首都</mx:data>
</mx:Object>
<mx:Object>
<mx:label>巴黎</mx:label>
<mx:data>法国的首都</mx:data>
</mx:Object>
</mx:Array>
<mx:Panel
title="我的{dy}个fiex应用程序">
<mx:Label
text="物品"/>
<mx:ComboBox id="myCombo"
dataProvider="{coffeeArray}"/>
<mx:Text text="描述:
{myCombo.selectedItem.data}"/>
<mx:Button label="Add to Cart"
click="addToCart()"/>
<mx:List id="cart"
dataProvider="{cartArray}">
</mx:List>
</mx:Panel>
</mx:Application>