Flex中如何通过moveDivider()和getDividerAt()函数在程序代码中动态改变HDividedBox容器部分大小的例子
By Minidxer | October 17, 2008
接下来的例子演示了Flex中如何通过moveDivider()和getDividerAt()函数,在程序代码中动态改变HDividedBox容器部分大小
让我们先来看一下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:ApplicationControlBar dock="true">
- <!-- Move the divider 20 pixels to the left for as long as the
- Button control is pressed (autoRepeat=true). -->
- <mx:Button label="x-=20"
- autoRepeat="true"
- buttonDown="hdivbox.moveDivider(0, -20);" />
- <!-- Move the divider 20 pixels to the right for as long as the
- Button control is pressed (autoRepeat=true). -->
- <mx:Button label="x+=20"
- autoRepeat="true"
- buttonDown="hdivbox.moveDivider(0, 20);" />
- <mx:Spacer width="50" />
- <!-- Move the divider to 100 pixels from the left. -->
- <mx:Button label="x=100"
- click="hdivbox.getDividerAt(0).x = 100;" />
- <!-- Move the divider to 420 pixels from the left. -->
- <mx:Button label="x=420"
- click="hdivbox.getDividerAt(0).x = 420;" />
- </mx:ApplicationControlBar>
- <mx:HDividedBox id="hdivbox" width="100%" height="100%">
- <mx:VBox backgroundColor="haloGreen" width="100%" height="100%">
- <!-- children -->
- </mx:VBox>
- <mx:VBox backgroundColor="haloBlue" width="100%" height="100%">
- <!-- children -->
- </mx:VBox>
- </mx:HDividedBox>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
HDividedBox |
No Comments » |
1,370 views
Tags: getDividerAt(), HDividedBox, moveDivider(), VDividedBox