In a previous example, “Displaying icons in a Flex PopUpButton control”, we saw how you can display icons in a PopUpButton control’s pop up menu.
The following example shows how you can display an icon in a Flex PopUpButton control’s main button by setting the icon style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/03/displaying-a-main-icon-in-a-flex-popupbutton-control/ -->
<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.Alert;
import mx.controls.Menu;
[Bindable]
[Embed("assets/asterisk_orange.png")]
private var asteriskOrangeIcon:Class;
[Bindable]
private var menu:Menu;
private function popUpButton_initialize():void {
menu = new Menu();
menu.dataProvider = arr;
}
]]>
</mx:Script>
<mx:Array id="arr">
<mx:Object label="Alert" />
<mx:Object label="Button" />
<mx:Object label="ButtonBar" />
<mx:Object label="CheckBox" />
<mx:Object label="ColorPicker" />
<mx:Object label="ComboBox" />
</mx:Array>
<mx:PopUpButton id="popUpButton"
label="Please select an item"
icon="{asteriskOrangeIcon}"
popUp="{menu}"
initialize="popUpButton_initialize();" />
</mx:Application>
View source is enabled in the following example.
You could also set the icon style in an external .CSS file or in an <mx:Style /> block, as shown in the following snippet:
<mx:Style>
PopUpButton {
icon: Embed("assets/asterisk_orange.png");
}
</mx:Style>
Or, you could set the icon style in ActionScript, as shown in the following snippet:
<mx:Script>
<![CDATA[
[Embed("assets/asterisk_orange.png")]
private var asteriskOrangeIcon:Class;
private function popUpButton_initialize():void {
popUpButton.setStyle("icon", asteriskOrangeIcon);
}
]]>
</mx:Script>




Can anyone tell me how can I change the size of closeButtonSkin of TitleWindow.
Default,closeButtonSkin of TitleWindow is a fixed size,now I need make it bigger.
Can anyone help me?
Thank you.