<?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; close()</title>
	<atom:link href="http://blog.flexexamples.com/tag/close/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>Detecting when an Alert control is closed in Flex</title>
		<link>http://blog.flexexamples.com/2008/05/01/detecting-when-an-alert-control-is-closed-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/05/01/detecting-when-an-alert-control-is-closed-in-flex/#comments</comments>
		<pubDate>Fri, 02 May 2008 04:48:42 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Alert]]></category>
		<category><![CDATA[close()]]></category>
		<category><![CDATA[closeHandler]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/01/detecting-when-an-alert-control-is-closed-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can detect when a Flex Alert control is closed by listening for the close event by specifying the closeHandler parameter in the static Alert.show() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_show_closeHandler_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/05/01/detecting-when-an-alert-control-is-closed-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init();"&#62; &#60;mx:Script&#62; &#60;![CDATA[ [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can detect when a Flex Alert control is closed by listening for the <code>close</code> event by specifying the <code>closeHandler</code> parameter in the static <code>Alert.show()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-615"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_show_closeHandler_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/05/01/detecting-when-an-alert-control-is-closed-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

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

            private var alert:Alert;

            private function init():void {
                Alert.buttonWidth = 100;
                Alert.yesLabel += " (" + Alert.YES + ")";
                Alert.noLabel += " (" + Alert.NO + ")";
                Alert.okLabel += " (" + Alert.OK + ")";
                Alert.cancelLabel += " (" + Alert.CANCEL + ")";
            }

            private function showAlert():void {
                var flags:uint = 0;
                if (yesCheckBox.selected) flags += Alert.YES;
                if (noCheckBox.selected) flags += Alert.NO;
                if (okCheckBox.selected) flags += Alert.OK;
                if (cancelCheckBox.selected) flags += Alert.CANCEL;
                if (nonModalCheckBox.selected) flags += Alert.NONMODAL;
                alert = Alert.show("The quick brown fox jumped over the lazy dog.",
                                    "title",
                                    flags,
                                    null,
                                    alert_close);
            }

            private function alert_close(evt:CloseEvent):void {
                arrColl.addItem(evt);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ArrayCollection id="arrColl" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Show alert"
                click="showAlert();" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            itemRenderer="mx.controls.Label"
            width="100%"
            height="100%" /&gt;

    &lt;mx:HBox width="100%"&gt;
        &lt;mx:CheckBox id="yesCheckBox"
                label="Alert.YES"
                width="20%" /&gt;
        &lt;mx:CheckBox id="noCheckBox"
                label="Alert.NO"
                width="20%" /&gt;
        &lt;mx:CheckBox id="okCheckBox"
                label="Alert.OK"
                width="20%" /&gt;
        &lt;mx:CheckBox id="cancelCheckBox"
                label="Alert.CANCEL"
                width="20%" /&gt;
        &lt;mx:CheckBox id="nonModalCheckBox"
                label="Alert.NONMODAL"
                width="20%" /&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_show_closeHandler_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/Alert_show_closeHandler_test/bin/main.html" width="100%" height="400"></iframe></p>
<p>For another example, see <a href="http://blog.flexexamples.com/2007/07/18/detecting-which-button-a-user-pressed-to-dismiss-an-alert-dialog/">&#8220;Detecting which button a user pressed to dismiss an Alert dialog&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when an Alert control is closed in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/05/01/detecting-when-an-alert-control-is-closed-in-flex/',contentID: 'post-615',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'close(),closeHandler',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/05/01/detecting-when-an-alert-control-is-closed-in-flex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Determining when the DateField control is opened or closed in Flex</title>
		<link>http://blog.flexexamples.com/2008/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/#comments</comments>
		<pubDate>Thu, 01 May 2008 06:57:03 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DateField]]></category>
		<category><![CDATA[close()]]></category>
		<category><![CDATA[DropdownEvent]]></category>
		<category><![CDATA[itemRenderer]]></category>
		<category><![CDATA[open()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can determine when the Flex DateField control&#8217;s is opened or closed by listening for the open or close events.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_open_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/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.events.DropdownEvent; private function dateField_openClose(evt:DropdownEvent):void { arrColl.addItem(evt); [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can determine when the Flex DateField control&#8217;s is opened or closed by listening for the <code>open</code> or <code>close</code> events.</p>
<p>Full code after the jump.</p>
<p><span id="more-614"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_open_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/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.DropdownEvent;

            private function dateField_openClose(evt:DropdownEvent):void {
                arrColl.addItem(evt);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ArrayCollection id="arrColl" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:DateField id="dateField"
                open="dateField_openClose(event);"
                close="dateField_openClose(event);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            itemRenderer="mx.controls.Label"
            width="100%"
            height="100%" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_open_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/DateField_open_test/bin/main.html" width="100%" height="350"></iframe></p>
<p>And here is the &#8220;same&#8221; example, but in ActionScript instead of MXML:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_open_test_2/bin/srcview/source/comps/MyDateField.as.html">comps/MyDateField.as</a></p>
<pre class="code">
/** http://blog.flexexamples.com/2008/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/ */
package comps {
    import mx.collections.ArrayCollection;
    import mx.containers.VBox;
    import mx.controls.DataGrid;
    import mx.controls.DateField;
    import mx.controls.Label;
    import mx.core.Application;
    import mx.core.ClassFactory;
    import mx.events.DropdownEvent;

    public class MyDateField extends VBox {

        [Bindable]
        private var arrColl:ArrayCollection;

        private var dateField:DateField;
        private var dataGrid:DataGrid;

        public function MyDateField() {
            super();
            init();
        }

        private function init():void {
            arrColl = new ArrayCollection();

            dateField = new DateField();
            dateField.addEventListener(DropdownEvent.OPEN, dateField_openClose);
            dateField.addEventListener(DropdownEvent.CLOSE, dateField_openClose);

            dataGrid = new DataGrid();
            dataGrid.dataProvider = arrColl;
            dataGrid.itemRenderer = new ClassFactory(mx.controls.Label);
            dataGrid.percentWidth = 100;
            dataGrid.percentHeight = 100;

            Application.application.appControlBar.addChild(dateField);

            addChild(dataGrid)
        }

        private function dateField_openClose(evt:DropdownEvent):void {
            arrColl.addItem(evt);
        }
    }
}
</pre>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_open_test_2/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/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:comps="comps.*"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:ApplicationControlBar id="appControlBar" dock="true" /&gt;

    &lt;comps:MyDateField width="100%" height="100%" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DateField_open_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/DateField_open_test_2/bin/main.html" width="100%" height="350"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Determining when the DateField control is opened or closed in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/',contentID: 'post-614',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'close(),DropdownEvent,itemRenderer,open()',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/04/30/determining-when-the-datefield-control-is-opened-or-closed-in-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating custom pop-up windows with the PopUpManager class (redux)</title>
		<link>http://blog.flexexamples.com/2008/03/20/creating-custom-pop-up-windows-with-the-popupmanager-class-redux/</link>
		<comments>http://blog.flexexamples.com/2008/03/20/creating-custom-pop-up-windows-with-the-popupmanager-class-redux/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 01:35:37 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[PopUpManager]]></category>
		<category><![CDATA[TitleWindow]]></category>
		<category><![CDATA[centerPopUp()]]></category>
		<category><![CDATA[close()]]></category>
		<category><![CDATA[createPopUp()]]></category>
		<category><![CDATA[showCloseButton]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/20/creating-custom-pop-up-windows-with-the-popupmanager-class-redux/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/08/06/creating-custom-pop-up-windows-with-the-popupmanager-class/">&#8220;Creating custom pop-up windows with the PopUpManager class&#8221;</a>, we saw how you could use ActionScript to create pop up windows using the PopUpManager class in Flex.</p> <p>In the following example we see how you can create a custom MXML component and pass the class name to the static PopUpManager.createPopUp() method [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2007/08/06/creating-custom-pop-up-windows-with-the-popupmanager-class/">&#8220;Creating custom pop-up windows with the PopUpManager class&#8221;</a>, we saw how you could use ActionScript to create pop up windows using the PopUpManager class in Flex.</p>
<p>In the following example we see how you can create a custom MXML component and pass the class name to the static <code>PopUpManager.createPopUp()</code> method to display the pop up.</p>
<p>Full code after the jump.</p>
<p><span id="more-568"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpManager_createPopUp_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/03/20/creating-custom-pop-up-windows-with-the-popupmanager-class-redux/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.managers.PopUpManager;

            private function launchMoreInfo():void {
                var win:Dialog = PopUpManager.createPopUp(this, Dialog, true) as Dialog;
                PopUpManager.centerPopUp(win);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="button"
                label="Click for more information"
                click="launchMoreInfo();" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpManager_createPopUp_test/bin/srcview/source/Dialog.mxml.html">Dialog.mxml</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- Dialog.mxml --&gt;
&lt;mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        title="More information"
        showCloseButton="true"
        width="400"
        height="300"
        close="titleWindow_close(event);"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;

            private function titleWindow_close(evt:CloseEvent):void {
                PopUpManager.removePopUp(this);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:String id="info" source="info.txt" /&gt;

    &lt;mx:TextArea id="txt"
            htmlText="{info}"
            focusAlpha="0.0"
            width="100%"
            height="100%" /&gt;

&lt;/mx:TitleWindow&gt;
</pre>
<p class="download">info.txt</p>
<pre class="code">
&lt;font size="+2"&gt;&lt;i&gt;More Information...&lt;/i&gt;&lt;/font&gt;
&lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec at arcu in lacus iaculis ultricies. Vivamus consectetuer. Donec vulputate aliquam leo. Nam metus. Aliquam nulla odio, ultrices vitae, nonummy eget, viverra accumsan, tellus. Curabitur neque ante, nonummy ut, fermentum eu, elementum a, ligula. Fusce hendrerit lectus ac velit. Suspendisse lorem pede, sagittis ac, fermentum non, auctor quis, nulla. Integer eu lacus sit amet justo vestibulum sodales. In euismod tellus eget magna. Vestibulum sed ante. Suspendisse eros libero, gravida ac, cursus et, porta vitae, lectus.&lt;/p&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpManager_createPopUp_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/PopUpManager_createPopUp_test/bin/main.html" width="100%" height="400"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating custom pop-up windows with the PopUpManager class (redux) on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/03/20/creating-custom-pop-up-windows-with-the-popupmanager-class-redux/',contentID: 'post-568',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'centerPopUp(),close(),createPopUp(),showCloseButton',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/03/20/creating-custom-pop-up-windows-with-the-popupmanager-class-redux/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Detecting when the Flex PopUpButton control is opened or closed</title>
		<link>http://blog.flexexamples.com/2008/02/18/detecting-when-the-flex-popupbutton-control-is-opened-or-closed/</link>
		<comments>http://blog.flexexamples.com/2008/02/18/detecting-when-the-flex-popupbutton-control-is-opened-or-closed/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 07:21:01 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[PopUpButton]]></category>
		<category><![CDATA[close()]]></category>
		<category><![CDATA[open()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/18/detecting-when-the-flex-popupbutton-control-is-opened-or-closed/</guid>
		<description><![CDATA[<p>The following example shows how you can detect when the Flex PopUpButton control is opened or closed by listening for the open or close event.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_open_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/02/18/detecting-when-the-flex-popupbutton-control-is-opened-or-closed/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Style&#62; PopUpButton { popUpStyleName: myCustomPopUpStyleName; } .myCustomPopUpStyleName { fontWeight: [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can detect when the Flex PopUpButton control is opened or closed by listening for the <code>open</code> or <code>close</code> event.</p>
<p>Full code after the jump.</p>
<p><span id="more-474"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_open_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/18/detecting-when-the-flex-popupbutton-control-is-opened-or-closed/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        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.events.ListEvent;
            import mx.controls.Menu;
            import mx.controls.Alert;
            import mx.events.DropdownEvent;
            import mx.utils.ObjectUtil;

            [Bindable]
            private var menu:Menu;

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

            private function popUpButton_open(evt:DropdownEvent):void {
                arrColl.addItem(evt);
            }

            private function popUpButton_close(evt:DropdownEvent):void {
                arrColl.addItem(evt);
            }

            private function dataGrid_itemClick(evt:ListEvent):void {
                var obj:DropdownEvent = evt.currentTarget.selectedItem;
                var str:String = "(empty string)";
                if (obj.triggerEvent) {
                    str = obj.triggerEvent.toString();
                }
                Alert.show(str, "triggerEvent:");
            }
        ]]&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:ArrayCollection id="arrColl" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:PopUpButton id="popUpButton"
                label="Select a control..."
                popUp="{menu}"
                initialize="init();"
                open="popUpButton_open(event);"
                close="popUpButton_close(event);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            variableRowHeight="true"
            width="100%"
            height="100%"
            itemClick="dataGrid_itemClick(event);"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn dataField="type"
                    width="100" /&gt;
            &lt;mx:DataGridColumn dataField="triggerEvent"
                    itemRenderer="mx.controls.Label"
                    wordWrap="true" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/PopUpButton_open_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_open_test/bin/main.html" width="100%" height="400"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when the Flex PopUpButton control is opened or closed on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/02/18/detecting-when-the-flex-popupbutton-control-is-opened-or-closed/',contentID: 'post-474',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'close(),open()',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/18/detecting-when-the-flex-popupbutton-control-is-opened-or-closed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programmatically opening and closing ComboBox controls in Flex</title>
		<link>http://blog.flexexamples.com/2007/12/13/programmatically-opening-and-closing-combobox-controls-in-flex/</link>
		<comments>http://blog.flexexamples.com/2007/12/13/programmatically-opening-and-closing-combobox-controls-in-flex/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 05:56:19 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[NumberValidator]]></category>
		<category><![CDATA[close()]]></category>
		<category><![CDATA[closeDuration]]></category>
		<category><![CDATA[open()]]></category>
		<category><![CDATA[openDuration]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/13/programmatically-opening-and-closing-combobox-controls-in-flex/</guid>
		<description><![CDATA[<p>The following examples show how you can programmatically open and close a ComboBox control&#8217;s drop down menu in Flex by using the open() and close() methods of the ComboBox class in Flex.</p> <p>Full code after the jump.</p> <p></p> <p>The following example shows how you can open and close a ComboBox control&#8217;s drop down menu by [...]]]></description>
			<content:encoded><![CDATA[<p>The following examples show how you can programmatically open and close a ComboBox control&#8217;s drop down menu in Flex by using the <code>open()</code> and <code>close()</code> methods of the ComboBox class in Flex.</p>
<p>Full code after the jump.</p>
<p><span id="more-364"></span></p>
<p>The following example shows how you can open and close a ComboBox control&#8217;s drop down menu by rolling over a Button control on the display list.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_open_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/12/13/programmatically-opening-and-closing-combobox-controls-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="open"
                rollOver="comboBox.open();"
                enabled="false" /&gt;
        &lt;mx:Button label="close"
                rollOver="comboBox.close();"
                enabled="false" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:ComboBox id="comboBox"
            openDuration="2000"
            closeDuration="1000"&gt;
        &lt;mx:dataProvider&gt;
            &lt;mx:Array&gt;
                &lt;mx:Object label="one" /&gt;
                &lt;mx:Object label="two" /&gt;
                &lt;mx:Object label="three" /&gt;
                &lt;mx:Object label="four" /&gt;
                &lt;mx:Object label="five" /&gt;
                &lt;mx:Object label="six" /&gt;
            &lt;/mx:Array&gt;
        &lt;/mx:dataProvider&gt;
    &lt;/mx:ComboBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_open_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/ComboBox_open_test/bin/main.html" width="100%" height="200"></iframe></p>
<p>The following example shows how you can open a ComboBox control&#8217;s drop down menu using ActionScript if the combo box fails validation (if it doesn&#8217;t have an item selected, for example):</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_errorString_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/12/13/programmatically-opening-and-closing-combobox-controls-in-flex/ --&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.ValidationResultEvent;
            import mx.controls.Alert;

            private function numberValidator_invalid(evt:ValidationResultEvent):void {
                comboBox.errorString = "Please select a thing";
                comboBox.open();
            }

            private function numberValidator_valid(evt:ValidationResultEvent):void {
                comboBox.errorString = "";
                Alert.show("Success");
            }

            private function validateCheckBox():void {
                numberValidator.validate(comboBox.selectedIndex);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:NumberValidator id="numberValidator"
            minValue="0"
            invalid="numberValidator_invalid(event);"
            valid="numberValidator_valid(event);" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="validate"
                click="validateCheckBox();" /&gt;
        &lt;mx:Button label="reset"
                click="comboBox.selectedIndex = -1;" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:ComboBox id="comboBox"
            prompt="Please select a thing..."
            openDuration="2000"
            closeDuration="1000"
            close="validateCheckBox();"&gt;
        &lt;mx:dataProvider&gt;
            &lt;mx:Array&gt;
                &lt;mx:Object label="one" /&gt;
                &lt;mx:Object label="two" /&gt;
                &lt;mx:Object label="three" /&gt;
                &lt;mx:Object label="four" /&gt;
                &lt;mx:Object label="five" /&gt;
                &lt;mx:Object label="six" /&gt;
            &lt;/mx:Array&gt;
        &lt;/mx:dataProvider&gt;
    &lt;/mx:ComboBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ComboBox_errorString_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/ComboBox_errorString_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Programmatically opening and closing ComboBox controls in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/12/13/programmatically-opening-and-closing-combobox-controls-in-flex/',contentID: 'post-364',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'close(),closeDuration,open(),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/2007/12/13/programmatically-opening-and-closing-combobox-controls-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

