Using the class ObjectUtil in Adobe Flex

Adobe Flex is a framework designed to create RIA applications with the Flash Platform for its ease and that is becoming very popular in recent years. There is class called ObjectUtil , a static class with a series of methods to assist and expedite the development of their applications. I’ll show some examples of methods that use more.
numericCompare Compares two numeric values. return 0 is both numbers are NaN. 1 if only a is a NaN. -1 if only b is a NaN. -1 if a is less than b. 1 if a is greater than b. See an example:
[MXML]












[/MXML]
compare Compares the Objects and returns an integer value indicating if the first item is less than greater than or equal to the second item. This method will recursively compare properties on nested objects and will return as soon as a non-zero result is found. By default this method will recurse to the deepest level of any property. To change the depth for comparison specify a non-negative value for the depth parameter. Return 0 if a and b are null, NaN, or equal. Return 1 if a is null or greater than b. Return -1 if b is null or greater than a. See an example:

[MXML]








[/MXML]
dateCompare Working with dates always generates a bit of work, because you always have to make a series of checks, change formats etc. We have a method for comparing dates that can be very useful and streamline your work. dateCompare compares the two Date objects and returns an integer value indicating if the first Date object is before, equal to, or after the second item. Return 0 if a and b are equal (or both are null); -1 if a is before b (or b is null); 1 if a is after b (or a is null). See an example:
[MXML]












[/MXML]
stringCompare Compares two String values. Return 0 is both Strings are null. 1 if only a is null. -1 if only b is null. -1 if a precedes b. 1 if b precedes a. third parameter boolean specifies to perform a case insensitive compare, true, or not, false. See an example:
[MXML]












[/MXML]
toString works something like PHP’s print_r makes a readable object and all its hierarchical structure. See an example:
[MXML]








[/MXML]
copy Copies the specified Object and returns a reference to the copy. The copy is made using a native serialization technique. This means that custom serialization will be respected during the copy. This method is designed for copying data objects, such as elements of a collection.

DOWNLOAD SOURCE

See other methods:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/ObjectUtil.html
ActionScript 3.0 Reference for the Adobe Flash Platform

Was this article helpful? feel free to make a donation and help keep the blog in the air
ActionScript 3.0, Adobe AIR, Flex

Leave a Reply