<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" pageTitle="咖啡收藏示例">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable]
public var myArray:ArrayCollection = new ArrayCollection([
{label: "蓝山咖啡", data: "精致典雅"},
{label: "红海咖啡", data: "润滑而且芳香浓郁"},
{label: "安第斯山脉咖啡", data: "浓郁以及伴有辛辣口味"}
]);
[Bindable]
public var myCartArray:ArrayCollection = new ArrayCollection([]);
// 添加咖啡进list列表。
protected function addToCart():void
{
var selectedobj:Object = myCombo.selectedItem;
if(myCartArray.getItemIndex(selectedobj)<0) {
myCartArray.addItem(selectedobj);
}else {
trace("=>提示:改咖啡已经存在!");
}
}
]]>
</fx:Script>
<!--view-->
<s:Panel title="My First Flex" width="450" height="265" horizontalCenter="0" verticalCenter="0">
<s:Label x="14" y="10" fontSize="16" text="Coffee Blends"/>
<s:ComboBox id="myCombo" x="14" y="30" dataProvider="{myArray}"/>
<mx:Text x="10" y="65" width="150" height="53" text="描述:{myCombo.selectedItem.data};"/>
<s:Button x="94" y="125" label="购买" click="addToCart()"/>
<s:List id="myCart" dataProvider="{myCartArray}" x="10" y="158" width="154" height="69"/>
<s:Label x="192" y="10" width="85" fontSize="16" text="咖啡列表"/>
<s:List id="list" dataProvider="{myArray}" labelField="label" x="192" y="32" width="246" height="136"/>
</s:Panel>
</s:Application>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" pageTitle="咖啡收藏示例">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable]
public var myArray:ArrayCollection = new ArrayCollection([
{label: "蓝山咖啡", data: "精致典雅"},
{label: "红海咖啡", data: "润滑而且芳香浓郁"},
{label: "安第斯山脉咖啡", data: "浓郁以及伴有辛辣口味"}
]);
[Bindable]
public var myCartArray:ArrayCollection = new ArrayCollection([]);
// 添加咖啡进list列表。
protected function addToCart():void
{
var selectedobj:Object = myCombo.selectedItem;
if(myCartArray.getItemIndex(selectedobj)<0) {
myCartArray.addItem(selectedobj);
}else {
trace("=>提示:改咖啡已经存在!");
}
}
]]>
</fx:Script>
<!--view-->
<s:Panel title="My First Flex" width="450" height="265" horizontalCenter="0" verticalCenter="0">
<s:Label x="14" y="10" fontSize="16" text="Coffee Blends"/>
<s:ComboBox id="myCombo" x="14" y="30" dataProvider="{myArray}"/>
<mx:Text x="10" y="65" width="150" height="53" text="描述:{myCombo.selectedItem.data};"/>
<s:Button x="94" y="125" label="购买" click="addToCart()"/>
<s:List id="myCart" dataProvider="{myCartArray}" x="10" y="158" width="154" height="69"/>
<s:Label x="192" y="10" width="85" fontSize="16" text="咖啡列表"/>
<s:List id="list" dataProvider="{myArray}" labelField="label" x="192" y="32" width="246" height="136"/>
</s:Panel>
</s:Application>