天天看点

Flex学习(一)

进入年末,项目也开发得差不多了,只是偶尔需要出差安装我们系统,当然出差是男人们的事,也就不会让我出差了,因而最近时间比较充裕,就借此机会学习了一下Flex。刚开始学,是根据Flex3权威指南的视频教程来的,第一讲学完了,感觉还比较容易,第二讲一直没下下来,所以先对第一讲学的做个笔记。

一、新建工程:File——> New——>Flex Project——>Next ——>Finish

二、新建.mxml文件: 右键——>New——>MXML Application

具体代码如下:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:states>

<mx:State name="CartView">

<mx:SetProperty target="{products}" name="width" value="0"/>

<mx:SetProperty target="{products}" name="height" value="0"/>

<mx:SetProperty target="{CartBox}" name="width" value="100%"/>

<mx:AddChild relativeTo="{CartBox}" position="lastChild">

<mx:LinkButton label="Continue Shopping" click="this.currentState=''" id="linkbutton2"/>

</mx:AddChild>

<mx:RemoveChild target="{linkbutton1}"/>

<mx:AddChild relativeTo="{linkbutton2}" position="before">

<mx:DataGrid width="100%">

<mx:columns>

<mx:DataGridColumn headerText="Column 1" dataField="col1"/>

<mx:DataGridColumn headerText="Column 2" dataField="col2"/>

<mx:DataGridColumn headerText="Column 3" dataField="col3"/>

</mx:columns>

</mx:DataGrid>

</mx:AddChild>

</mx:State>

</mx:states>

<mx:ApplicationControlBar x="117" y="41" dock="true" height="90">

<mx:Canvas width="100%" height="100%">

<mx:Label x="0" y="0" text="Flex"/>

<mx:Label x="0" y="41" text="Grocer"/>

<mx:Button y="10" label="View Cart" id="btnViewCart" right="10"/>

<mx:Button y="10" label="Check Out" id="btnCheckOut" right="90"/>

</mx:Canvas>

</mx:ApplicationControlBar>

<mx:Label x="240" y="183" text="(c)2010,FlexGrocer"/>

<mx:HBox x="0" y="0" width="100%" height="100%">

<mx:VBox width="100%" height="100%" id="products">

<mx:Label text="Milk" id="prodName"/>

<mx:Label text="$1.99" id="price"/>

<mx:Button label="Add to Cart" id="add"/>

</mx:VBox>

<mx:VBox height="100%" id="CartBox">

<mx:Label text="Your Cart Total:$"/>

<mx:LinkButton label="View Cart" click="this.currentState='CartView'" id="linkbutton1"/>

</mx:VBox>

</mx:HBox>

</mx:Application>

继续阅读