Software and Technology Ramblings

June 9, 2007

ObjectUtil where have you been?

Filed under: Flex — Doug Hays @ 6:29 am

I’ve been writing Flex apps since I was 31. And now, when I look back on how dumb I was back then, it’s shocking. Writing my own date comparison methods and creating clone/copy methods by hand. Was I bored?

Well, I wish someone had noticed my stupidity and told me about mx.utils.ObjectUtil. What a fantastic collection of static functions. If you (who is even reading this?) aren’t using ObjectUtil in your Flex code, you should be.

My favorite functions:

  • compare – will compare the properties of two objects (even recursively) – this is great for trying to decide the equality of two objects that were returned from a web service or remote object call
  • copy – simple way to create a copy of an object. I’ve found this useful for purposefully breaking a data binding.
  • dateCompare – self-explanitory
  • toString – this is perhaps the greatest of all of them… for logging purposes, throw an Object at ObjectUtil.toString() and it’ll pretty-print the Object’s innards. It’s the var_dump of ActionScript

Enjoy,
Doug.

« Newer Posts

Powered by WordPress