進入年末,項目也開發得差不多了,隻是偶爾需要出差安裝我們系統,當然出差是男人們的事,也就不會讓我出差了,因而最近時間比較充裕,就借此機會學習了一下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>