-
Flex教程入门篇(五)
2009-06-14 02:03/点击数()
firstapp.mxml完整的代码: ?xml version=1.0? mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml !-- data model -- mx:Array id=coffeeArray mx:Object labelRed Sea/label dataSmooth and fragrant/data /mx:Object mx:Object labelAndes/lab
firstapp.mxml完整的代码:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >
<!-- data model -->
<mx:Array id="coffeeArray">
<mx:Object>
<label>Red Sea</label>
<data>Smooth and fragrant</data>
</mx:Object>
<mx:Object>
<label>Andes</label>
<data>Rich and pungent</data>
</mx:Object>
<mx:Object>
<label>Blue Mountain</label>
<data>Delicate and refined</data>
</mx:Object>
</mx:Array>
<mx:Script>
<![CDATA[
function addToCart():Void
{
cart.addItem(coffeeCombo.selectedItem.label,coffeeCombo.selectedItem.data);
}
]]>
</mx:Script>
<!-- view -->
<mx:Panel title="My First Flex App">
<mx:Label text="Coffee Blends"/>
<mx:ComboBox id="coffeeCombo" dataProvider="{coffeeArray}"/>
<mx:Text text="Description: {coffeeCombo.selectedItem.data}"/>
<mx:Button label="Add to Cart" click="addToCart()"/>
<mx:List id="cart"/>
</mx:Panel>
</mx:Application>
进一步学习在这个简单的例子中,我们学习了Flex的一些核心元素:容器、控件、数据模型、数据绑定和事件处理。你可以继续看本系列教程:
上一篇:Flex教程入门篇(四)
下一篇:Flex屏蔽并自定义鼠标右键菜单
