Flex中如何通过arrowButtonWidth样式自定义PopUpButton按钮宽度的例子
By Minidxer | March 12, 2009
接下来的例子演示了Flex中如何通过arrowButtonWidth样式,自定义PopUpButton按钮宽度。
让我们先来看一下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="top"
- backgroundColor="white">
- <mx:Style>
- PopUpButton {
- popUpStyleName: myCustomPopUpStyleName;
- }
- .myCustomPopUpStyleName {
- fontWeight: normal;
- textAlign: left;
- }
- </mx:Style>
- <mx:Script>
- <![CDATA[
- import mx.controls.Menu;
- private var menu:Menu;
- private function init():void {
- menu = new Menu();
- menu.labelField = "@label";
- menu.dataProvider = xmlList;
- popUpButton.popUp = menu;
- menu.maxWidth = popUpButton.width;
- }
- ]]>
- </mx:Script>
- <mx:XMLList id="xmlList">
- <node label="Alert" />
- <node label="Button" />
- <node label="ButtonBar" />
- <node label="CheckBox" />
- <node label="ColorPicker" />
- <node label="ComboBox" />
- </mx:XMLList>
- <mx:ApplicationControlBar dock="true">
- <mx:Form styleName="plain">
- <mx:FormItem label="arrowButtonWidth:">
- <mx:HSlider id="slider"
- minimum="16"
- maximum="64"
- value="16"
- snapInterval="1"
- tickInterval="4"
- showTrackHighlight="true"
- liveDragging="true" />
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
- <mx:PopUpButton id="popUpButton"
- label="Please select an item..."
- openAlways="true"
- arrowButtonWidth="{slider.value}"
- creationComplete="init();" />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
PopUpButton |
No Comments » |
398 views
Tags: arrowButtonWidth, PopUpButton