<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; Menu</title>
	<atom:link href="http://blog.flexexamples.com/category/halo/menu/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting a variable row height on an MX MenuBar control in Flex</title>
		<link>http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 01:54:34 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[Menu]]></category>
		<category><![CDATA[MenuBar]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[invalidateSize()]]></category>
		<category><![CDATA[menuShow]]></category>
		<category><![CDATA[variableRowHeight]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2502</guid>
		<description><![CDATA[<p>The following example shows how you can set a variable row height on an MX MenuBar control in Flex by listening for the menuShow event, setting the Boolean variableRowHeight property on the MenuEvent object&#8217;s menu property, and then calling the invalidateSize() method.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/ --&#62; &#60;mx:Application name=&#34;MenuBar_menuShow_menu_variableRowHeight_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; backgroundColor=&#34;white&#34;&#62; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set a variable row height on an MX MenuBar control in Flex by listening for the <code>menuShow</code> event, setting the Boolean <code>variableRowHeight</code> property on the MenuEvent object&#8217;s <code>menu</code> property, and then calling the <code>invalidateSize()</code> method.</p>
<p><span id="more-2502"></span></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;MenuBar_menuShow_menu_variableRowHeight_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.events.MenuEvent;</span>
&nbsp;
<span style="color: #339933;">            protected function mBar_menuShowHandler(evt:MenuEvent):void {</span>
<span style="color: #339933;">                evt.menu.variableRowHeight = ch.selected;</span>
<span style="color: #339933;">                evt.menu.invalidateSize();</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ApplicationControlBar</span> dock=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:CheckBox</span> id=<span style="color: #ff0000;">&quot;ch&quot;</span> label=<span style="color: #ff0000;">&quot;variableRowHeight&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ApplicationControlBar</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:MenuBar</span> id=<span style="color: #ff0000;">&quot;mBar&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">            menuShow=<span style="color: #ff0000;">&quot;mBar_menuShowHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XMLListCollection</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XMLList</span> xmlns=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;menu label=<span style="color: #ff0000;">&quot;File...&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;New&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Open&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Save&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Save As&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;fake type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Exit&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/menu<span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;menu label=<span style="color: #ff0000;">&quot;Edit...&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Cut&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Copy&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Paste&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;fake type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Undo&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Redo&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;fake type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;radio button&quot;</span> type=<span style="color: #ff0000;">&quot;radio&quot;</span> toggled=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;check box&quot;</span> type=<span style="color: #ff0000;">&quot;check&quot;</span> toggled=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/menu<span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:XMLList</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:XMLListCollection</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:MenuBar</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>If you&#8217;re using Flex 4.0+, you can use the following code:<br />
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;MenuBar_menuShow_menu_variableRowHeight_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:CheckBox</span> id=<span style="color: #ff0000;">&quot;ch&quot;</span> label=<span style="color: #ff0000;">&quot;variableRowHeight&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.events.MenuEvent;</span>
&nbsp;
<span style="color: #000000;">            protected function mBar_menuShowHandler<span style="color: #66cc66;">&#40;</span>evt:MenuEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                evt.menu.variableRowHeight = ch.selected;</span>
<span style="color: #000000;">                evt.menu.invalidateSize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:MenuBar</span> id=<span style="color: #ff0000;">&quot;mBar&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;@label&quot;</span></span>
<span style="color: #000000;">            horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> top=<span style="color: #ff0000;">&quot;20&quot;</span></span>
<span style="color: #000000;">            menuShow=<span style="color: #ff0000;">&quot;mBar_menuShowHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:XMLListCollection</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:XMLList</span> xmlns=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;menu label=<span style="color: #ff0000;">&quot;File...&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;New&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Open&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Save&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Save As&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;fake type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Exit&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/menu<span style="color: #7400FF;">&gt;</span></span>
                    <span style="color: #000000;">&lt;menu label=<span style="color: #ff0000;">&quot;Edit...&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Cut&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Copy&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Paste&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;fake type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Undo&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;Redo&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;fake type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;radio button&quot;</span> type=<span style="color: #ff0000;">&quot;radio&quot;</span> toggled=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                        <span style="color: #000000;">&lt;item label=<span style="color: #ff0000;">&quot;check box&quot;</span> type=<span style="color: #ff0000;">&quot;check&quot;</span> toggled=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                    <span style="color: #000000;">&lt;/menu<span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:XMLList</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:XMLListCollection</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:MenuBar</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting a variable row height on an MX MenuBar control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/',contentID: 'post-2502',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'Gumbo,invalidateSize(),Menu,menuShow,variableRowHeight',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2010/02/19/setting-a-variable-row-height-on-an-mx-menubar-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Displaying icons in a Flex PopUpButton control (Redux)</title>
		<link>http://blog.flexexamples.com/2009/01/20/displaying-icons-in-a-flex-popupbutton-control-redux/</link>
		<comments>http://blog.flexexamples.com/2009/01/20/displaying-icons-in-a-flex-popupbutton-control-redux/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 07:53:11 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[iconField]]></category>
		<category><![CDATA[labelField]]></category>
		<category><![CDATA[popUp]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/01/20/displaying-icons-in-a-flex-popupbutton-control-redux/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/01/24/displaying-icons-in-a-flex-popupbutton-control/">&#8220;Displaying icons in a Flex PopUpButton control&#8221;</a>, we saw how you could add icons to a PopUpButton control&#8217;s nested menu using an Array data provider.</p> <p>The following example shows you how you can add icons to a pop up menu in a PopUpButton control in Flex by specifying the iconField [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/01/24/displaying-icons-in-a-flex-popupbutton-control/">&#8220;Displaying icons in a Flex PopUpButton control&#8221;</a>, we saw how you could add icons to a PopUpButton control&#8217;s nested menu using an Array data provider.</p>
<p>The following example shows you how you can add icons to a pop up menu in a PopUpButton control in Flex by specifying the <code>iconField</code> property in the PopUpButton control&#8217;s nested Menu control using an XML data provider.</p>
<p>Full code after the jump.</p>
<p><span id="more-939"></span></p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/01/20/displaying-icons-in-a-flex-popupbutton-control-redux/ --&gt;
&lt;mx:Application name="PopUpButton_popUp_Menu_iconField_test_2"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="horizontal"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Menu;

            [Embed("assets/Button.png")]
            public const ButtonIcon:Class;

            [Embed("assets/ButtonBar.png")]
            public const ButtonBarIcon:Class;

            [Embed("assets/CheckBox.png")]
            public const CheckBoxIcon:Class;

            [Embed("assets/ColorPicker.png")]
            public const ColorPickerIcon:Class;

            [Bindable]
            private var menu:Menu;

            private function initMenu():void {
                menu = new Menu();
                menu.dataProvider = xmlList;
                menu.labelField = "@label";
                menu.iconField = "@icon";
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Style&gt;
        PopUpButton {
            popUpStyleName: myCustomPopUpStyleName;
        }

        .myCustomPopUpStyleName {
           fontWeight: normal;
           textAlign: left;
        }
    &lt;/mx:Style&gt;

    &lt;mx:XMLList id="xmlList"&gt;
        &lt;node label="Alert" /&gt;
        &lt;node label="Button" icon="ButtonIcon" /&gt;
        &lt;node label="ButtonBar" icon="ButtonBarIcon" /&gt;
        &lt;node label="CheckBox" icon="CheckBoxIcon" /&gt;
        &lt;node label="ColorPicker" icon="ColorPickerIcon" /&gt;
    &lt;/mx:XMLList&gt;

    &lt;mx:PopUpButton id="popUpButton"
            label="Select a control..."
            popUp="{menu}"
            preinitialize="initMenu();"
            creationComplete="popUpButton.open();" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Displaying icons in a Flex PopUpButton control (Redux) on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/01/20/displaying-icons-in-a-flex-popupbutton-control-redux/',contentID: 'post-939',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'iconField,labelField,popUp',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2009/01/20/displaying-icons-in-a-flex-popupbutton-control-redux/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Adding a horizontal separator to a Flex PopUpButton control&#8217;s pop up menu (redux)</title>
		<link>http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/</link>
		<comments>http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 01:33:55 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[popUp]]></category>
		<category><![CDATA[variableRowHeight]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/</guid>
		<description><![CDATA[<p>In a previous example, <a href="">&#8220;Adding a horizontal separator to a Flex PopUpButton control&#8217;s pop up menu&#8221;</a>, we saw how you could add a horizontal separator to a PopUpButton control&#8217;s pop up menu in Flex by setting the type attribute to &#8220;separator&#8221; in the menu&#8217;s data provider.</p> <p>The following example shows how you can adjust [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="">&#8220;Adding a horizontal separator to a Flex PopUpButton control&#8217;s pop up menu&#8221;</a>, we saw how you could add a horizontal separator to a PopUpButton control&#8217;s pop up menu in Flex by setting the type attribute to &#8220;separator&#8221; in the menu&#8217;s data provider.</p>
<p>The following example shows how you can adjust the amount of empty space around the horizontal separator by setting the Boolean <code>variableRowHeight</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-816"></span></p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/ --&gt;
&lt;mx:Application name="PopUpButton_popUp_dataProvider_type_test_2"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        PopUpButton {
            popUpStyleName: myCustomPopUpStyleName;
            closeDuration: 0;
            openDuration: 0;
        }

        .myCustomPopUpStyleName {
            fontWeight: normal;
            textAlign: left;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![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();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="One" /&gt;
        &lt;mx:Object label="Two" /&gt;
        &lt;mx:Object label="Three" /&gt;
        &lt;mx:Object type="separator" /&gt;
        &lt;mx:Object label="The quick brown fox jumped over the lazy dog." /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:CheckBox id="checkBox"
                label="variableRowHeight:"
                labelPlacement="left"
                selected="true"
                change="checkBox_change(event);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:PopUpButton id="popUpButton"
            label="PopUpButton with separator"
            openAlways="true"
            initialize="popUpButton_initialize();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test_3/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test_3/bin/main.html" width="100%" height="250"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/ --&gt;
&lt;mx:Application name="PopUpButton_popUp_dataProvider_type_test_2"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.PopUpButton;
            import mx.containers.ApplicationControlBar;
            import mx.events.ListEvent;
            import mx.controls.ButtonLabelPlacement;
            import mx.controls.CheckBox;
            import mx.controls.Menu;

            private var arr:Array;
            private var checkBox:CheckBox;
            private var menu:Menu;
            private var popUpButton:PopUpButton;

            private function init():void {
                arr = [];
                arr.push({label:"One"});
                arr.push({label:"Two"});
                arr.push({label:"Three"});
                arr.push({type:"separator"});
                arr.push({label:"The quick brown fox jumped over the lazy dog."});

                checkBox = new CheckBox();
                checkBox.label = "variableRowHeight:";
                checkBox.labelPlacement = ButtonLabelPlacement.LEFT;
                checkBox.selected = true;
                checkBox.addEventListener(Event.CHANGE, checkBox_change);

                var appControlBar:ApplicationControlBar;
                appControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(checkBox);
                addChild(appControlBar);
                application.controlBar = appControlBar;

                menu = new Menu();
                menu.dataProvider = arr;
                menu.variableRowHeight = checkBox.selected;

                var cssObj:CSSStyleDeclaration = new CSSStyleDeclaration(".myCustomPopUpStyleName");
                cssObj.setStyle("fontWeight", "normal");
                cssObj.setStyle("textAlign", "left");

                popUpButton = new PopUpButton();
                popUpButton.popUp = menu;
                popUpButton.label = "PopUpButton with separator";
                popUpButton.openAlways = true;
                popUpButton.setStyle("popUpStyleName", "myCustomPopUpStyleName");
                popUpButton.setStyle("closeDuration", 0);
                popUpButton.setStyle("openDuration", 0);
                addChild(popUpButton);
            }

            private function checkBox_change(evt:Event):void {
                menu.variableRowHeight = checkBox.selected;
                menu.invalidateSize();
                popUpButton.open();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding a horizontal separator to a Flex PopUpButton control\&#039;s pop up menu (redux) on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/',contentID: 'post-816',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'popUp,variableRowHeight',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting the open duration on a Menu control in Flex</title>
		<link>http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 06:08:23 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[openDuration]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set the open duration of a Flex Menu control by setting the openDuration style.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Menu_openDuration_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" initialize="init();"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Menu; import mx.events.SliderEvent; private var menu:Menu; private function init():void [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the open duration of a Flex Menu control by setting the <code>openDuration</code> style.</p>
<p>Full code after the jump.</p>
<p><span id="more-752"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Menu_openDuration_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Menu;
            import mx.events.SliderEvent;

            private var menu:Menu;

            private function init():void {
                menu = Menu.createMenu(null, xmlDP, true);
                menu.labelField = "@label";
                menu.showRoot = false;
                menu.variableRowHeight = true;
            }

            private function showMenu():void {
                menu.show(50, 50);
            }

            private function slider_change(evt:SliderEvent):void {
                menu.hide();
                menu.setStyle("openDuration", evt.value);
                showMenu();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="xmlDP" source="menuDataProvider.xml" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="openDuration:"&gt;
                &lt;mx:HSlider id="slider"
                        minimum="0"
                        maximum="2000"
                        value="250"
                        snapInterval="50"
                        tickInterval="100"
                        liveDragging="true"
                        change="slider_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
        &lt;mx:Spacer width="100%" /&gt;
        &lt;mx:Button label="Open Menu"
                click="showMenu();"/&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Menu_openDuration_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Menu_openDuration_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>You can also set the <code>openDuration</code> style in an external .CSS file or &lt;mx:Style /&gt; block, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Menu_openDuration_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Style&gt;
        Menu {
            openDuration: 1500;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Menu;
            import mx.events.SliderEvent;

            private var menu:Menu;

            private function init():void {
                menu = Menu.createMenu(null, xmlDP, true);
                menu.labelField = "@label";
                menu.showRoot = false;
                menu.variableRowHeight = true;
            }

            private function showMenu():void {
                menu.show(50, 50);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="xmlDP" source="menuDataProvider.xml" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Spacer width="100%" /&gt;
        &lt;mx:Button label="Open Menu"
                click="showMenu();"/&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the open duration on a Menu control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/',contentID: 'post-752',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'openDuration',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/08/19/setting-the-open-duration-on-a-menu-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Determining if a check box menu item is toggled in a Flex PopUpButton control&#8217;s pop up menu</title>
		<link>http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/</link>
		<comments>http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 06:29:40 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[dataDescriptor]]></category>
		<category><![CDATA[getType()]]></category>
		<category><![CDATA[isToggled()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/</guid>
		<description><![CDATA[<p>The following example shows you how you can determine if a check box menu item in a Flex PopUpButton control was checked or not by using the change event on the pop up menu along with the dataDescriptor property and isToggled() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataDescriptor_isToggled_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows you how you can determine if a check box menu item in a Flex PopUpButton control was checked or not by using the <code>change</code> event on the pop up menu along with the <code>dataDescriptor</code> property and <code>isToggled()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-509"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataDescriptor_isToggled_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        PopUpButton {
            popUpStyleName: MyCustomPopUpStyleName;
        }

        .MyCustomPopUpStyleName {
            fontWeight: normal;
            textAlign: left;
        }

        .redModal {
            modalTransparencyColor: red;
            modalTransparency: 0.8;
        }

        .greenModal {
            modalTransparencyColor: haloGreen;
            modalTransparency: 0.8;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.MenuEvent;
            import mx.controls.Menu;
            import mx.controls.Alert;

            private var menu:Menu;
            private function init():void {
                menu = new Menu();
                menu.variableRowHeight = true;
                menu.dataProvider = arr;
                menu.addEventListener(MenuEvent.CHANGE, menu_change);
                popUpButton.popUp = menu;
            }

            private function menu_change(evt:MenuEvent):void {
                switch (menu.dataDescriptor.getType(evt.item)) {
                    case "check":
                        if (menu.dataDescriptor.isToggled(evt.item)) {
                            application.styleName = "greenModal";
                            Alert.show("\\"" + evt.item.label + "\\" was checked");
                        } else {
                            application.styleName = "redModal";
                            Alert.show("\\"" + evt.item.label + "\\" was not checked");
                        }
                        break;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="Option 1"
                type="check"
                toggled="true" /&gt;
        &lt;mx:Object label="Option 2"
                type="check"
                toggled="true" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:PopUpButton id="popUpButton"
            label="Click to open..."
            openAlways="true"
            initialize="init();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataDescriptor_isToggled_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataDescriptor_isToggled_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Determining if a check box menu item is toggled in a Flex PopUpButton control\&#039;s pop up menu on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/',contentID: 'post-509',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'dataDescriptor,getType(),isToggled()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/02/11/determining-if-a-check-box-menu-item-is-toggled-in-a-flex-popupbutton-controls-pop-up-menu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reducing the vertical space around a separator in a Flex PopUpButton control&#8217;s pop up menu by enabling variable row heights</title>
		<link>http://blog.flexexamples.com/2008/01/31/reducing-the-vertical-space-around-a-separator-in-a-flex-popupbutton-controls-pop-up-menu-by-enabling-variable-row-heights/</link>
		<comments>http://blog.flexexamples.com/2008/01/31/reducing-the-vertical-space-around-a-separator-in-a-flex-popupbutton-controls-pop-up-menu-by-enabling-variable-row-heights/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 02:48:37 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[popUp]]></category>
		<category><![CDATA[variableRowHeight]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/31/reducing-the-vertical-space-around-a-separator-in-a-flex-popupbutton-controls-pop-up-menu-by-enabling-variable-row-heights/</guid>
		<description><![CDATA[<p>The following example shows how you can reduce the amount of whitespace around a PopUpButton control&#8217;s pop up menu by setting the variableRowHeight property on the menu in Flex.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_variableRowHeight_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/01/31/reducing-the-vertical-space-around-a-separator-in-a-flex-popupbutton-controls-pop-up-menu-by-enabling-variable-row-heights/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" verticalAlign="top" backgroundColor="white"&#62; &#60;mx:Style&#62; PopUpButton { openDuration: 0; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can reduce the amount of whitespace around a PopUpButton control&#8217;s pop up menu by setting the <code>variableRowHeight</code> property on the menu in Flex.</p>
<p>Full code after the jump.</p>
<p><span id="more-504"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_variableRowHeight_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/31/reducing-the-vertical-space-around-a-separator-in-a-flex-popupbutton-controls-pop-up-menu-by-enabling-variable-row-heights/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="horizontal"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        PopUpButton {
            openDuration: 0;
            closeDuration: 0;
            fontWeight: normal;
            textAlign: left;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.FlexEvent;
            import mx.controls.Menu;
            import mx.utils.ObjectUtil;

            private function popUpButton1_initialize():void {
                var menu:Menu = new Menu();
                menu.showRoot = false;
                menu.labelField = "@label";
                menu.dataProvider = ObjectUtil.copy(dp);
                popUpButton1.popUp = menu;
            }

            private function popUpButton2_initialize():void {
                var menu:Menu = new Menu();
                menu.showRoot = false;
                menu.labelField = "@label";
                menu.dataProvider = ObjectUtil.copy(dp);
                menu.variableRowHeight = true;
                popUpButton2.popUp = menu;
            }

            private function popUpButton_creationComplete(evt:FlexEvent):void {
                var pUB:PopUpButton = evt.currentTarget as PopUpButton;
                // resize and open
                pUB.popUp.width = pUB.width;
                pUB.open();
            }

            private function openPopUpButtons():void {
                popUpButton1.open();
                popUpButton2.open();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="dp" source="dp.xml" /&gt;

    &lt;mx:PopUpButton id="popUpButton1"
            label="variableRowHeight = false"
            openAlways="true"
            width="250"
            initialize="popUpButton1_initialize();"
            creationComplete="popUpButton_creationComplete(event);"
            open="openPopUpButtons();" /&gt;

    &lt;mx:PopUpButton id="popUpButton2"
            label="variableRowHeight = true"
            openAlways="true"
            width="250"
            initialize="popUpButton2_initialize();"
            creationComplete="popUpButton_creationComplete(event);"
            open="openPopUpButtons();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_variableRowHeight_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_variableRowHeight_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Reducing the vertical space around a separator in a Flex PopUpButton control\&#039;s pop up menu by enabling variable row heights on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/31/reducing-the-vertical-space-around-a-separator-in-a-flex-popupbutton-controls-pop-up-menu-by-enabling-variable-row-heights/',contentID: 'post-504',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'popUp,variableRowHeight',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/31/reducing-the-vertical-space-around-a-separator-in-a-flex-popupbutton-controls-pop-up-menu-by-enabling-variable-row-heights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding checkboxes, radiobuttons, and sub-menus to a Flex PopUpButton control&#8217;s pop up menu</title>
		<link>http://blog.flexexamples.com/2008/01/29/adding-checkboxes-radiobuttons-and-sub-menus-to-a-flex-popupbutton-controls-pop-up-menu/</link>
		<comments>http://blog.flexexamples.com/2008/01/29/adding-checkboxes-radiobuttons-and-sub-menus-to-a-flex-popupbutton-controls-pop-up-menu/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 06:59:21 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/29/adding-checkboxes-radiobuttons-and-sub-menus-to-a-flex-popupbutton-controls-pop-up-menu/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/">&#8220;Adding a horizontal separator to a Flex PopUpButton control&#8217;s pop up menu&#8221;</a>, we saw how you can add horizontal separators to a PopUpButton control&#8217;s pop up menu by setting the type attribute to &#8220;separator&#8221;. So, &#8220;what other special types are there?&#8221;, you may be asking, as it turns out you [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/">&#8220;Adding a horizontal separator to a Flex PopUpButton control&#8217;s pop up menu&#8221;</a>, we saw how you can add horizontal separators to a PopUpButton control&#8217;s pop up menu by setting the type attribute to &#8220;separator&#8221;. So, &#8220;what other special types are there?&#8221;, you may be asking, as it turns out you can create folders with sub-menus, checkboxes, radiobuttons, and even disable item selection.</p>
<p><span id="more-499"></span></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2008/01/29/adding-checkboxes-radiobuttons-and-sub-menus-to-a-flex-popupbutton-controls-pop-up-menu/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;top&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
        PopUpButton {
            popUpStyleName: myCustomPopUpStyleName;
        }
&nbsp;
        .myCustomPopUpStyleName {
            fontWeight: normal;
            textAlign: left;
        }
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Style</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XML</span> id=<span style="color: #ff0000;">&quot;xmlDP&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;root<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;The quick brown fox jumped over the lazy dog.&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;Lorem ipsum (disabled).&quot;</span> enabled=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;parent&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;child1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;/node<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;parent (disabled)&quot;</span> enabled=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;child1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;child2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;child3&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;/node<span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;">&lt;node type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;type=check&quot;</span> id=<span style="color: #ff0000;">&quot;ch&quot;</span> type=<span style="color: #ff0000;">&quot;check&quot;</span> toggled=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;type=check&quot;</span> id=<span style="color: #ff0000;">&quot;ch&quot;</span> type=<span style="color: #ff0000;">&quot;check&quot;</span> toggled=<span style="color: #ff0000;">&quot;true&quot;</span> enabled=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node type=<span style="color: #ff0000;">&quot;separator&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;1) type=radio&quot;</span> type=<span style="color: #ff0000;">&quot;radio&quot;</span> groupName=<span style="color: #ff0000;">&quot;radioGroup&quot;</span> toggled=<span style="color: #ff0000;">&quot;true&quot;</span>  <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;2) type=radio&quot;</span> type=<span style="color: #ff0000;">&quot;radio&quot;</span> groupName=<span style="color: #ff0000;">&quot;radioGroup&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;3) type=radio&quot;</span> type=<span style="color: #ff0000;">&quot;radio&quot;</span> groupName=<span style="color: #ff0000;">&quot;radioGroup&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;">&lt;node label=<span style="color: #ff0000;">&quot;4) type=radio&quot;</span> type=<span style="color: #ff0000;">&quot;radio&quot;</span> groupName=<span style="color: #ff0000;">&quot;radioGroup&quot;</span> enabled=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;/root<span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:XML</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.controls.Menu;</span>
&nbsp;
<span style="color: #339933;">            private var menu:Menu;</span>
&nbsp;
<span style="color: #339933;">            private function init():void {</span>
<span style="color: #339933;">                menu = new Menu();</span>
<span style="color: #339933;">                menu.labelField = &quot;@label&quot;;</span>
<span style="color: #339933;">                menu.dataProvider = xmlDP;</span>
<span style="color: #339933;">                menu.showRoot = false;</span>
<span style="color: #339933;">                menu.width = popUpButton.width;</span>
<span style="color: #339933;">                popUpButton.popUp = menu;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:PopUpButton</span> id=<span style="color: #ff0000;">&quot;popUpButton&quot;</span></span>
<span style="color: #000000;">            label=<span style="color: #ff0000;">&quot;Please select an item&quot;</span></span>
<span style="color: #000000;">            openAlways=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">            creationComplete=<span style="color: #ff0000;">&quot;init();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test_2/bin/main.html" width="100%" height="350"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding checkboxes, radiobuttons, and sub-menus to a Flex PopUpButton control\&#039;s pop up menu on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/29/adding-checkboxes-radiobuttons-and-sub-menus-to-a-flex-popupbutton-controls-pop-up-menu/',contentID: 'post-499',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'type',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/29/adding-checkboxes-radiobuttons-and-sub-menus-to-a-flex-popupbutton-controls-pop-up-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a horizontal separator to a Flex PopUpButton control&#8217;s pop up menu</title>
		<link>http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/</link>
		<comments>http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 05:17:47 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[popUp]]></category>
		<category><![CDATA[separator]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/</guid>
		<description><![CDATA[<p>The following example shows how you can add a horizontal separator to a PopUpButton control&#8217;s pop up menu in Flex by setting the type attribute to &#8220;separator&#8221; in the menu&#8217;s data provider.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top" backgroundColor="white"&#62; &#60;mx:Style&#62; PopUpButton [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can add a horizontal separator to a PopUpButton control&#8217;s pop up menu in Flex by setting the <code>type</code> attribute to &#8220;separator&#8221; in the menu&#8217;s data provider.</p>
<p>Full code after the jump.</p>
<p><span id="more-494"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        PopUpButton {
            popUpStyleName: myCustomPopUpStyleName;
        }

        .myCustomPopUpStyleName {
            fontWeight: normal;
            textAlign: left;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Menu;

            private var menu:Menu;

            private function popUpButton_initialize():void {
                menu = new Menu();
                menu.dataProvider = arr;
                popUpButton.popUp = menu;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="One" /&gt;
        &lt;mx:Object label="Two" /&gt;
        &lt;mx:Object label="Three" /&gt;
        &lt;mx:Object type="separator" /&gt;
        &lt;mx:Object label="The quick brown fox jumped over the lazy dog." /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:PopUpButton id="popUpButton"
            label="PopUpButton with separator"
            openAlways="true"
            initialize="popUpButton_initialize();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_dataProvider_type_test/bin/main.html" width="100%" height="250"></iframe></p>
<p>If you happen to be using an XML (or XMLList) data provider, you could use the following code instead:</p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;top&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Style&gt;
        PopUpButton {
            popUpStyleName: myCustomPopUpStyleName;
        }

        .myCustomPopUpStyleName {
            fontWeight: normal;
            textAlign: left;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Menu;

            private var menu:Menu;

            private function popUpButton_initialize():void {
                menu = new Menu();
                <strong style="color:red;">menu.labelField = &quot;@label&quot;;</strong>
                menu.dataProvider = xml;
                popUpButton.popUp = menu;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    <strong style="color:red;">&lt;mx:XMLList id=&quot;xml&quot;&gt;
        &lt;node label=&quot;One&quot; /&gt;
        &lt;node label=&quot;Two&quot; /&gt;
        &lt;node label=&quot;Three&quot; /&gt;
        &lt;node type=&quot;separator&quot; /&gt;
        &lt;node label=&quot;The quick brown fox jumped over the lazy dog.&quot; /&gt;
    &lt;/mx:XMLList&gt;</strong>

    &lt;mx:PopUpButton id=&quot;popUpButton&quot;
            label=&quot;PopUpButton with separator&quot;
            openAlways=&quot;true&quot;
            initialize=&quot;popUpButton_initialize();&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="new">For an example on reducing the amount of whitespace around the separator in a Menu control, see <a href="http://blog.flexexamples.com/2008/10/02/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu-redux/">&#8220;Adding a horizontal separator to a Flex PopUpButton control&#8217;s pop up menu (redux)&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding a horizontal separator to a Flex PopUpButton control\&#039;s pop up menu on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/',contentID: 'post-494',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'popUp,separator',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/29/adding-a-horizontal-separator-to-a-flex-popupbutton-controls-pop-up-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting the width on a Flex PopUpButton control&#8217;s pop up menu</title>
		<link>http://blog.flexexamples.com/2008/01/28/setting-the-width-on-a-flex-popupbutton-controls-pop-up-menu/</link>
		<comments>http://blog.flexexamples.com/2008/01/28/setting-the-width-on-a-flex-popupbutton-controls-pop-up-menu/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 04:19:13 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[popUp]]></category>
		<category><![CDATA[width]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/28/setting-the-width-on-a-flex-popupbutton-controls-pop-up-menu/</guid>
		<description><![CDATA[<p>The following example shows how you can set the width of a PopUpButton control&#8217;s pop up menu in Flex by setting the width property on the Menu control instance.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_width_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/01/28/setting-the-width-on-a-flex-popupbutton-controls-pop-up-menu/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Menu; [Bindable] [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the width of a PopUpButton control&#8217;s pop up menu in Flex by setting the <code>width</code> property on the Menu control instance.</p>
<p>Full code after the jump.</p>
<p><span id="more-489"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_width_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/28/setting-the-width-on-a-flex-popupbutton-controls-pop-up-menu/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Menu;

            [Bindable]
            private var menu:Menu;

            private function init():void {
                menu = new Menu();
                menu.dataProvider = arr;
                menu.width = 200;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="Lorem ipsum dolor sit amet, consectetuer adipiscing elit." /&gt;
        &lt;mx:Object label="Donec sit amet dui nec pede aliquam auctor." /&gt;
        &lt;mx:Object label="Integer vestibulum sodales dui." /&gt;
        &lt;mx:Object label="Sed nonummy ligula et tortor." /&gt;
        &lt;mx:Object label="Aenean varius neque vel felis." /&gt;
        &lt;mx:Object label="Phasellus venenatis ipsum sit amet nisi." /&gt;
        &lt;mx:Object label="Nullam vitae turpis et ipsum cursus venenatis." /&gt;
        &lt;mx:Object label="Pellentesque tincidunt pede non arcu." /&gt;
        &lt;mx:Object label="Aliquam ut massa quis ante dignissim egestas." /&gt;
        &lt;mx:Object label="Curabitur facilisis velit sit amet metus." /&gt;
        &lt;mx:Object label="Vivamus ornare massa ac massa." /&gt;
        &lt;mx:Object label="Nam accumsan rutrum purus." /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:PopUpButton id="popUpButton"
            label="Please select an item"
            popUp="{menu}"
            initialize="init();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_width_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUp_width_test/bin/main.html" width="100%" height="350"></iframe></p>
<p>As you can see, if the label doesn&#8217;t fit within the nested Menu control, the test is truncated with &#8220;&#8230;&#8221; and mousing over the item will display the full text in a tool tip.</p>
<p class="new">&#8220;Anonymous&#8221; beat me to it below in the comments, but if you want to set a fixed or maximum width for the pop up menu, you can set the <code>width</code> property or <code>maxWidth</code> property so that the menu&#8217;s width doesn&#8217;t exceed the width of the PopUpButton control, as seen in the following snippet:</p>
<pre class="code">
private function init():void {
    menu = new Menu();
    menu.dataProvider = arr;
    <strong style="color:red;">menu.maxWidth = popUpButton.width;</strong>
}
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting the width on a Flex PopUpButton control\&#039;s pop up menu on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/28/setting-the-width-on-a-flex-popupbutton-controls-pop-up-menu/',contentID: 'post-489',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'popUp,width',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/28/setting-the-width-on-a-flex-popupbutton-controls-pop-up-menu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Aligning labels in a Flex PopUpButton control&#8217;s pop up menu</title>
		<link>http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/</link>
		<comments>http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 04:47:09 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Menu]]></category>
		<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[popUp]]></category>
		<category><![CDATA[popUpStyleName]]></category>
		<category><![CDATA[textAlign]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/</guid>
		<description><![CDATA[<p>The following example shows you how you can align the labels in a PopUpButton control&#8217;s pop up menu in Flex by setting the popUpStyleName and textAlign styles.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUpStyleName_textAlign_test/main.mxml">View MXML</a></p> &#60;?xml version=&#34;1.0&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/ --&#62; &#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;top&#34; backgroundColor=&#34;white&#34;&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Menu; import mx.events.MenuEvent; [Bindable] private [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows you how you can align the labels in a PopUpButton control&#8217;s pop up menu in Flex by setting the <code>popUpStyleName</code> and <code>textAlign</code> styles.</p>
<p>Full code after the jump.</p>
<p><span id="more-463"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUpStyleName_textAlign_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;top&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Menu;
            import mx.events.MenuEvent;

            [Bindable]
            private var menu:Menu;

            private function initMenu():void {
                menu = new Menu();
                menu.dataProvider = arr;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id=&quot;arr&quot;&gt;
        &lt;mx:Object label=&quot;Button&quot; /&gt;
        &lt;mx:Object label=&quot;ButtonBar&quot; /&gt;
        &lt;mx:Object label=&quot;ColorPicker&quot; /&gt;
        &lt;mx:Object label=&quot;ComboBox&quot; /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:Style&gt;
        .myCustomPopUpStyleName {
           <strong style="color:red;">textAlign: left;</strong>
        }
    &lt;/mx:Style&gt;

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:PopUpButton id=&quot;popUpButton&quot;
                label=&quot;Select a control...&quot;
                popUp=&quot;{menu}&quot;
                popUpStyleName=&quot;myCustomPopUpStyleName&quot;
                preinitialize=&quot;initMenu();&quot; /&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUpStyleName_textAlign_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUpStyleName_textAlign_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>Or, if a dynamic example is a bit more your style&#8230;</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUpStyleName_textAlign_test_2/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ItemClickEvent;
            import mx.controls.Menu;
            import mx.events.MenuEvent;

            [Bindable]
            private var menu:Menu;

            private function initMenu():void {
                menu = new Menu();
                menu.dataProvider = arr;
            }

            private function toggleButtonBar_itemClick(evt:ItemClickEvent):void {
                var obj:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".myCustomPopUpStyleName");
                obj.setStyle("textAlign", evt.label);
                popUpButton.open();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="Button" /&gt;
        &lt;mx:Object label="ButtonBar" /&gt;
        &lt;mx:Object label="ColorPicker" /&gt;
        &lt;mx:Object label="ComboBox" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:Style&gt;
        .myCustomPopUpStyleName {
           textAlign: left;
        }
    &lt;/mx:Style&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="textAlign:"&gt;
                &lt;mx:ToggleButtonBar id="toggleButtonBar"
                        selectedIndex="0"
                        itemClick="toggleButtonBar_itemClick(event);"&gt;
                    &lt;mx:dataProvider&gt;
                        &lt;mx:Array&gt;
                            &lt;mx:Object label="left" /&gt;
                            &lt;mx:Object label="center" /&gt;
                            &lt;mx:Object label="right" /&gt;
                        &lt;/mx:Array&gt;
                    &lt;/mx:dataProvider&gt;
                &lt;/mx:ToggleButtonBar&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:PopUpButton id="popUpButton"
            label="Select a control..."
            popUp="{menu}"
            popUpStyleName="myCustomPopUpStyleName"
            preinitialize="initMenu();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUpStyleName_textAlign_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_popUpStyleName_textAlign_test_2/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Aligning labels in a Flex PopUpButton control\&#039;s pop up menu on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/',contentID: 'post-463',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'popUp,popUpStyleName,textAlign',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/18/aligning-labels-in-a-flex-popupbutton-controls-pop-up-menu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

