Flex權威指南3學習筆記之一——介面知識(二)

來源:互聯網
上載者:User

使用基於條件的約束的布局

1.在viewCart按鈕和checkOut按鈕添加分別添加屬性“right="90"”、“right="10"”,刪除x屬性,y屬性值設為0,如下所示:

 

<mx:Button label="View Cart" id="btnViewCart" right="90" y="0"/></p><p><mx:Button label="Checkout" id="btnCheckout" right="10" y="0"/><br />

兩個按鈕將會靠右顯示,不用將座標定死。

2.另外 著作權標籤如下顯示

<mx:Label text="(c) 2006, FlexGrocer" bottom="10" right="10"/>

 

顯示效果如下所示:

3.在第一個VBox下再添加一個VBox,用於顯示購物車資訊

<mx:VBox height="100%" id="cartBox"><br /><mx:Label text="Your Cart Total: $"/><br /><mx:LinkButton label="View Cart"/></mx:VBox>

4.所有代碼如下所示:

<?xml version="1.0" encoding="utf-8"?><br /><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><br /><mx:ApplicationControlBar dock="true" width="100%" height="90"><br /><mx:Canvas width="100%" height="100%"><br /><mx:Label x="0" y="0" text="Flex"/><br /><mx:Label x="0" y="41" text="GROCER"/><br /><mx:Button label="View Cart" id="btnViewCart" right="90" y="0"/><br /><mx:Button label="Checkout" id="btnCheckout" right="10" y="0"/><br /></mx:Canvas><br /></mx:ApplicationControlBar><br /><mx:Label text="(c) 2006, FlexGrocer" bottom="10" right="10"/><br /><mx:HBox x="0" y="0" width="100%" height="100%" id="bodyBox"><br /><mx:VBox width="100%" height="100%" id="products"><br /><mx:Label text="Milk" id="prodName"/><br /><mx:Label text="$1.99" id="price"/><br /><mx:Button label="Add To Cart" id="add"/><br /></mx:VBox><br /><mx:VBox height="100%" id="cartBox"><br /><mx:Label text="Your Cart Total: $"/><br /><mx:LinkButton label="View Cart"/><br /></mx:VBox><br /></mx:HBox></p><p></mx:Application>

5.運行結果為:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.