<?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; DropdownEvent</title>
	<atom:link href="http://blog.flexexamples.com/tag/dropdownevent/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>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>
	</channel>
</rss>

