Flex中如何通过variableRowHeight属性调整PopUpButton控件下拉菜单分隔符间隔的例子
By Minidxer | October 4, 2008
接下来的例子演示了Flex中如何通过variableRowHeight属性,调整PopUpButton控件下拉菜单分隔符间隔。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application name="PopUpButton_popUp_dataProvider_type_test_2"
- xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="top"
- backgroundColor="white">
- <mx:Style>
- PopUpButton {
- popUpStyleName: myCustomPopUpStyleName;
- closeDuration: 0;
- openDuration: 0;
- }
- .myCustomPopUpStyleName {
- fontWeight: normal;
- textAlign: left;
- }
- </mx:Style>
- <mx:Script>
- <![CDATA[
- import mx.controls.Menu;
- private var menu:Menu;
- private function popUpButton_initialize():void {
- menu = new Menu();
- menu.dataProvider = arr;
- menu.variableRowHeight = checkBox.selected;
- popUpButton.popUp = menu;
- popUpButton.open();
- }
- private function checkBox_change(evt:Event):void {
- menu.variableRowHeight = checkBox.selected;
- menu.invalidateSize();
- popUpButton.open();
- }
- ]]>
- </mx:Script>
- <mx:Array id="arr">
- <mx:Object label="One" />
- <mx:Object label="Two" />
- <mx:Object label="Three" />
- <mx:Object type="separator" />
- <mx:Object label="The quick brown fox jumped over the lazy dog." />
- </mx:Array>
- <mx:ApplicationControlBar dock="true">
- <mx:CheckBox id="checkBox"
- label="variableRowHeight:"
- labelPlacement="left"
- selected="true"
- change="checkBox_change(event);" />
- </mx:ApplicationControlBar>
- <mx:PopUpButton id="popUpButton"
- label="PopUpButton with separator"
- openAlways="true"
- initialize="popUpButton_initialize();" />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Flex |
Tags: Menu, popUp, PopUpButton, variableRowHeight