Flex中如何通过direction属性改变Box容器(HBox或VBox)方向的例子
By Minidxer | February 1, 2009
接下来的例子演示了Flex中如何通过direction属性,改变Box容器(HBox或VBox)方向。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Style>
- .myBox {
- paddingLeft: 10;
- paddingRight: 10;
- paddingTop: 10;
- paddingBottom: 10;
- backgroundColor: haloSilver;
- }
- </mx:Style>
- <mx:Script>
- <![CDATA[
- import mx.events.ListEvent;
- import mx.containers.BoxDirection;
- private function comboBox_init():void {
- var arr:Array = [];
- arr.push({label:BoxDirection.HORIZONTAL});
- arr.push({label:BoxDirection.VERTICAL});
- comboBox.dataProvider = arr;
- }
- private function comboBox_change(evt:ListEvent):void {
- box.direction = comboBox.selectedLabel;
- }
- ]]>
- </mx:Script>
- <mx:ApplicationControlBar dock="true">
- <mx:Form styleName="plain">
- <mx:FormItem label="direction:">
- <mx:ComboBox id="comboBox"
- initialize="comboBox_init();"
- change="comboBox_change(event);" />
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
- <mx:Box id="box" direction="horizontal" styleName="myBox">
- <mx:Image source="Button.png" toolTip="Button" />
- <mx:Image source="ButtonBar.png" toolTip="ButtonBar" />
- <mx:Image source="CheckBox.png" toolTip="CheckBox" />
- <mx:Image source="ColorPicker.png" toolTip="ColorPicker" />
- <mx:Image source="ComboBox.png" toolTip="ComboBox" />
- </mx:Box>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
VBox |
No Comments » |
Tags: Box, BoxDirection, direction