<?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; ObjectUtil</title>
	<atom:link href="http://blog.flexexamples.com/category/objectutil/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>Getting information about a class using the ObjectUtil class in Flex</title>
		<link>http://blog.flexexamples.com/2009/02/12/getting-information-about-a-class-using-the-objectutil-class-in-flex/</link>
		<comments>http://blog.flexexamples.com/2009/02/12/getting-information-about-a-class-using-the-objectutil-class-in-flex/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 06:21:04 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ObjectUtil]]></category>
		<category><![CDATA[getClassInfo()]]></category>
		<category><![CDATA[Gumbo]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/02/12/getting-information-about-a-class-using-the-objectutil-class-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can get information about a class/object by using the static ObjectUtil.getClassInfo() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2009/02/12/getting-information-about-a-class-using-the-objectutil-class-in-flex/ --&#62; &#60;mx:Application name="ObjectUtil_getClassInfo_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.utils.ObjectUtil; import mx.controls.HRule; private function init():void { var obj:Object = ObjectUtil.getClassInfo(HRule); textArea.text [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can get information about a class/object by using the static <code>ObjectUtil.getClassInfo()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-962"></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/2009/02/12/getting-information-about-a-class-using-the-objectutil-class-in-flex/ --&gt;
&lt;mx:Application name="ObjectUtil_getClassInfo_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.utils.ObjectUtil;
            import mx.controls.HRule;

            private function init():void {
                var obj:Object = ObjectUtil.getClassInfo(HRule);
                textArea.text = ObjectUtil.toString(obj);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:TextArea id="textArea"
            editable="false"
            fontSize="12"
            width="100%"
            height="100%"
            creationComplete="init();" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Getting information about a class using the ObjectUtil class in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/02/12/getting-information-about-a-class-using-the-objectutil-class-in-flex/',contentID: 'post-962',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'getClassInfo(),Gumbo',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/02/12/getting-information-about-a-class-using-the-objectutil-class-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Performing case [in]sensitive sorts using the DataGrid control in Flex</title>
		<link>http://blog.flexexamples.com/2008/03/07/performing-case-insensitive-sorts-using-the-datagrid-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/03/07/performing-case-insensitive-sorts-using-the-datagrid-control-in-flex/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 03:03:21 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[DataGridColumn]]></category>
		<category><![CDATA[NumericCompare]]></category>
		<category><![CDATA[ObjectUtil]]></category>
		<category><![CDATA[sortCompareFunction]]></category>
		<category><![CDATA[stringCompare]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/07/performing-case-insensitive-sorts-using-the-datagrid-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can perform numeric sorts, case sensitive sorts, or case insensitive sorts in the Flex DataGrid control by setting a custom sort compare function on the DataGridColumn using the sortCompareFunction property, the static ObjectUtil.numericCompare() method, and the static ObjectUtil.stringCompare() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_sortCompareFunction_test/main.mxml">View MXML</a></p> [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can perform numeric sorts, case sensitive sorts, or case insensitive sorts in the Flex DataGrid control by setting a custom sort compare function on the DataGridColumn using the <code>sortCompareFunction</code> property, the static <code>ObjectUtil.numericCompare()</code> method, and the static <code>ObjectUtil.stringCompare()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-549"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_sortCompareFunction_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/03/07/performing-case-insensitive-sorts-using-the-datagrid-control-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.utils.ObjectUtil;

            private function index_sortCompareFunc(itemA:Object, itemB:Object):int {
                // Make sure itemA has an "index" property.
                if (!itemA.hasOwnProperty("index")) {
                    itemA.index = null;
                }
                // Make sure itemB has an "index" property.
                if (!itemB.hasOwnProperty("index")) {
                    itemB.index = null;
                }
                // Perform a numeric sort.
                return ObjectUtil.numericCompare(itemA.index, itemB.index);
            }

            private function value_sortCompareFunc(itemA:Object, itemB:Object):int {
                // Make sure itemA has a "value" property.
                if (!itemA.hasOwnProperty("value")) {
                    itemA.value = null;
                }
                // Make sure itemB has a "value" property.
                if (!itemB.hasOwnProperty("value")) {
                    itemB.value = null;
                }
                /**
                 * Perform a string sort. If the checkbox is selected
                 * do a case insensitive sort, otherwise, dont.
                 */
                return ObjectUtil.stringCompare(itemA.value, itemB.value, checkBox.selected);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ArrayCollection id="arrColl"&gt;
        &lt;mx:source&gt;
            &lt;mx:Array&gt;
                &lt;mx:Object index="1" value="apple" /&gt;
                &lt;mx:Object index="200" value="Bear" /&gt;
                &lt;mx:Object index="3" value="corn" /&gt;
                &lt;mx:Object index="40" value="Dragon" /&gt;
                &lt;mx:Object value="eggplant" /&gt;
                &lt;mx:Object index="5" /&gt;
            &lt;/mx:Array&gt;
        &lt;/mx:source&gt;
    &lt;/mx:ArrayCollection&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:CheckBox id="checkBox"
                label="case insensitive search:"
                labelPlacement="left"
                selected="true" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid" dataProvider="{arrColl}"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn dataField="index"
                    sortCompareFunction="index_sortCompareFunc" /&gt;
            &lt;mx:DataGridColumn dataField="value"
                    sortCompareFunction="value_sortCompareFunc" /&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/DataGridColumn_sortCompareFunction_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/DataGridColumn_sortCompareFunction_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Performing case [in]sensitive sorts using the DataGrid control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/03/07/performing-case-insensitive-sorts-using-the-datagrid-control-in-flex/',contentID: 'post-549',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'sortCompareFunction,stringCompare',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/07/performing-case-insensitive-sorts-using-the-datagrid-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Flex applications using the describeType() method and the ObjectUtil class</title>
		<link>http://blog.flexexamples.com/2007/12/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/</link>
		<comments>http://blog.flexexamples.com/2007/12/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 07:18:28 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ObjectUtil]]></category>
		<category><![CDATA[describeType()]]></category>
		<category><![CDATA[toString()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/</guid>
		<description><![CDATA[<p>The following example shows how you can debug your Flex applications using the describeType() method (in the flash.utils package), as well as the static ObjectUtil.toString() method to display information about objects in Flex.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/describeType_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/12/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="traceObj(progressBar);"&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can debug your Flex applications using the <code>describeType()</code> method (in the flash.utils package), as well as the static <code>ObjectUtil.toString()</code> method to display information about objects in Flex.</p>
<p>Full code after the jump.</p>
<p><span id="more-357"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/describeType_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/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="traceObj(progressBar);"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.utils.ObjectUtil;

            private function traceObj(target:Object):void {
                textArea1.text = ObjectUtil.toString(target);
                textArea2.text = describeType(target).toXMLString();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Form width="100%" height="100%"&gt;
        &lt;mx:FormItem label="target:"&gt;
            &lt;mx:ProgressBar id="progressBar"
                    labelPlacement="center"
                    indeterminate="true" /&gt;
        &lt;/mx:FormItem&gt;
        &lt;mx:FormItem label="ObjectUtil.toString(...):"
                width="100%"
                height="50%"&gt;
            &lt;mx:TextArea id="textArea1"
                    editable="false"
                    width="100%"
                    height="100%" /&gt;
        &lt;/mx:FormItem&gt;
        &lt;mx:FormItem label="describeType.toXMLString(...):"
                width="100%"
                height="50%"&gt;
            &lt;mx:TextArea id="textArea2"
                    editable="false"
                    width="100%"
                    height="100%" /&gt;
        &lt;/mx:FormItem&gt;
    &lt;/mx:Form&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/describeType_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/describeType_test/bin/main.html" width="100%" height="500"></iframe></p>
<p class="construction">There was an enhancement to the ObjectUtil class in Flex 3 (SDK build 187815 or later), where you can now use the <code>ObjectUtil.toString()</code> method on all display objects without getting a run time error.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Debugging Flex applications using the describeType() method and the ObjectUtil class on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/12/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/',contentID: 'post-357',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'describeType(),toString()',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/09/debugging-flex-applications-using-the-describetype-method-and-the-objectutil-class/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Creating unique identifiers for objects using the getUID() method</title>
		<link>http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/</link>
		<comments>http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 02:45:14 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ObjectUtil]]></category>
		<category><![CDATA[UIDUtil]]></category>
		<category><![CDATA[getUID()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/</guid>
		<description><![CDATA[<p>The following example shows how you can use the static UIDUtil.getUID() method to generate and retreive a unique identifier for an Object. The first time you click the Display UID button, an Alert control displays the generated UID and a string representation of the Object (yay ObjectUtil.toString()!). The second time you click the Display UID [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use the static <code>UIDUtil.getUID()</code> method to generate and retreive a unique identifier for an Object. The first time you click the Display UID button, an Alert control displays the generated UID and a string representation of the Object (yay <code>ObjectUtil.toString()</code>!). The second time you click the Display UID button, you&#8217;ll notice that a new parameter is added to the Object, mx_internal_uid.</p>
<p>Full code after the jump.</p>
<p><span id="more-266"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/UIDUtil_getUID_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/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/ --&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.controls.Alert;
            import mx.utils.ObjectUtil;
            import mx.utils.UIDUtil;

            private function displayUID():void {
                var text:String = ObjectUtil.toString(myObj);
                var title:String = UIDUtil.getUID(myObj);
                Alert.show(text, title);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Object id="myObj" name="peter" site="flexexamples.com" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Display UID"
                click="displayUID();" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/UIDUtil_getUID_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/UIDUtil_getUID_test/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating unique identifiers for objects using the getUID() method on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/',contentID: 'post-266',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'getUID()',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/11/01/creating-unique-identifiers-for-objects-using-the-getuid-method/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sorting date columns in a DataGrid</title>
		<link>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/</link>
		<comments>http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/#comments</comments>
		<pubDate>Sun, 12 Aug 2007 15:51:01 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[ObjectUtil]]></category>
		<category><![CDATA[dataTipFunction]]></category>
		<category><![CDATA[dateCompare()]]></category>
		<category><![CDATA[showDataTips]]></category>
		<category><![CDATA[sortCompareFunction]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/</guid>
		<description><![CDATA[<p>Here&#8217;s an example of sorting a column of dates in a Flex DataGrid. The dates start out as Strings (such as &#8220;04/14/1980&#8243;) so you create a custom sortCompareFunction on that DataGrid column which converts the strings to dates so Flex will sort the dates in sequential order (as oppsed to string order). Hope that helps [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an example of sorting a column of dates in a Flex DataGrid. The dates start out as Strings (such as &#8220;04/14/1980&#8243;) so you create a custom <code>sortCompareFunction</code> on that DataGrid column which converts the strings to dates so Flex will sort the dates in sequential order (as oppsed to string order). Hope that helps somebody out there.</p>
<p>I also created a little tooltip on the date column which shows the dates in a somewhat more readable form (&#8220;April 14 1980&#8243;) using the DataGridColumn object&#8217;s <code>showDataTips</code> and <code>dataTipFunction</code> properties.</p>
<p>Full code after the jump.</p>
<p><span id="more-81"></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/2007/08/12/sorting-date-columns-in-a-datagrid/ --&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;middle&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.utils.ObjectUtil;</span>
&nbsp;
<span style="color: #339933;">            private function date_sortCompareFunc(itemA:Object, itemB:Object):int {</span>
<span style="color: #339933;">                /* Date.parse() returns an int, but</span>
<span style="color: #339933;">                   ObjectUtil.dateCompare() expects two</span>
<span style="color: #339933;">                   Date objects, so convert String to</span>
<span style="color: #339933;">                   int to Date. */</span>
<span style="color: #339933;">                var dateA:Date = new Date(Date.parse(itemA.dob));</span>
<span style="color: #339933;">                var dateB:Date = new Date(Date.parse(itemB.dob));</span>
<span style="color: #339933;">                return ObjectUtil.dateCompare(dateA, dateB);</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function date_dataTipFunc(item:Object):String {</span>
<span style="color: #339933;">                return dateFormatter.format(item.dob);</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:ArrayCollection</span> id=<span style="color: #ff0000;">&quot;arrColl&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:source</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Array</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> name=<span style="color: #ff0000;">&quot;User A&quot;</span> dob=<span style="color: #ff0000;">&quot;04/14/1980&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> name=<span style="color: #ff0000;">&quot;User B&quot;</span> dob=<span style="color: #ff0000;">&quot;01/02/1975&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> name=<span style="color: #ff0000;">&quot;User C&quot;</span> dob=<span style="color: #ff0000;">&quot;12/30/1977&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> name=<span style="color: #ff0000;">&quot;User D&quot;</span> dob=<span style="color: #ff0000;">&quot;10/27/1968&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Array</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:source</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ArrayCollection</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DateFormatter</span> id=<span style="color: #ff0000;">&quot;dateFormatter&quot;</span> formatString=<span style="color: #ff0000;">&quot;MMMM D, YYYY&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGrid</span> id=<span style="color: #ff0000;">&quot;dataGrid&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{arrColl}&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:columns</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> dataField=<span style="color: #ff0000;">&quot;name&quot;</span></span>
<span style="color: #000000;">                    headerText=<span style="color: #ff0000;">&quot;Name:&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> dataField=<span style="color: #ff0000;">&quot;dob&quot;</span></span>
<span style="color: #000000;">                    headerText=<span style="color: #ff0000;">&quot;Date of birth:&quot;</span></span>
<span style="color: #000000;">                    sortCompareFunction=<span style="color: #ff0000;">&quot;date_sortCompareFunc&quot;</span></span>
<span style="color: #000000;">                    showDataTips=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #000000;">                    dataTipFunction=<span style="color: #ff0000;">&quot;date_dataTipFunc&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:columns</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:DataGrid</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/DataGrid_date_sort_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/DataGrid_date_sort_test/bin/main.html" width="100%" height="220"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Sorting date columns in a DataGrid on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/',contentID: 'post-81',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'dataTipFunction,dateCompare(),showDataTips,sortCompareFunction',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/08/12/sorting-date-columns-in-a-datagrid/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>

