[Flex] PopUpButton系列 —— 控制弹出菜单的透明度、可用、可选择状态

<?xml version="1.0" encoding="utf-8"?>
<!--控制弹出菜单的透明度、可用、可选择状态 PopUpButtonPopUpTranslucent.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.controls.Menu; import mx.events.FlexEvent; private var menu:Menu; protected function popUpButton_initializeHandler(event:FlexEvent):void { } protected function popUpButton_creationCompleteHandler(event:FlexEvent):void { menu = new Menu(); menu.labelField = "@label"; menu.dataProvider = xmlList; popUpButton.popUp = menu; menu.width = popUpButton.width; } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> <fx:Array id="arr"> <fx:Object label="《霹雳先锋》香港票房8916612" actor="Steven Chow"/> <fx:Object label="《捕风汉子》香港票房3149395" actor="Steven Chow"/> <fx:Object label="《小偷阿星》香港票房7968106 " actor="Steven Chow"/> <fx:Object type="separator"/> <fx:Object label="笑傲江湖之东方不败(1992)" type="check" actor="Jet Li"/> <fx:Object label="精武英雄(1994)" type="radio" actor="Jet Li"/> <fx:Object label="给爸爸的信(1995)" actor="Jet Li"/> </fx:Array> <fx:XMLList xmlns="" id="xmlList"> <node label="《霹雳先锋》香港票房8916612" type="radio" toggled="true" /> <node label="《捕风汉子》香港票房3149395"> <node label="child item" /> </node> <node label="《小偷阿星》香港票房7968106" /> <node type="separator" /> <node label="笑傲江湖之东方不败(1992)" type="check" toggled="true" /> <node label="精武英雄(1994)" /> <node label="给爸爸的信(1995)" enabled="false" /> </fx:XMLList> </fx:Declarations> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; mx|PopUpButton { popUpStyleName: myCustomPopUpStyleName; } /* mx|Menu{ fontWeight: normal; textAlign: left; chromeColor: blue; contentBackgroundAlpha:0.4; contentBackgroundColor:white; borderStyle: solid; } */ .myCustomPopUpStyleName { fontWeight: normal; textAlign: center; contentBackgroundAlpha:0.4; contentBackgroundColor:white; borderStyle: solid; } </fx:Style> <s:controlBarContent> <mx:PopUpButton id="popUpButton" label="Please select an item..." openAlways="true" initialize="popUpButton_initializeHandler(event)" creationComplete="popUpButton_creationCompleteHandler(event)" /> </s:controlBarContent> <s:BorderContainer backgroundAlpha="0.5" backgroundColor="haloSilver" width="100%" height="100%" /> </s:Application>

 

posted on 2016-02-17 15:02  晏过留痕  阅读(302)  评论(0编辑  收藏  举报