Category Archives: ObjectUtil

Performing case [in]sensitive sorts using the DataGrid control in Flex

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.

Full code after the jump.

Continue reading Performing case [in]sensitive sorts using the DataGrid control in Flex

Debugging Flex applications using the describeType() method and the ObjectUtil class

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.

Full code after the jump.

Continue reading Debugging Flex applications using the describeType() method and the ObjectUtil class

Creating unique identifiers for objects using the getUID() method

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 button, you’ll notice that a new parameter is added to the Object, mx_internal_uid.

Full code after the jump.

Continue reading Creating unique identifiers for objects using the getUID() method

Sorting date columns in a DataGrid

Here’s an example of sorting a column of dates in a Flex DataGrid. The dates start out as Strings (such as “04/14/1980”) 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 somebody out there.

I also created a little tooltip on the date column which shows the dates in a somewhat more readable form (“April 14 1980”) using the DataGridColumn object’s showDataTips and dataTipFunction properties.

Full code after the jump.

Continue reading Sorting date columns in a DataGrid