Archive for February, 2009

Getting Class of an Object in Flex

February 26, 2009

Frequently we may come across one requirement when we will be having one object and we want to know which class this object belongs to. In java, its as simple as object. getClass();

Flex also provides us with a class, mx.utils.ObjectUtil, which we can use for this purpose.

ObjectUtil.getClassInfo(object)

will return information about the class, and properties of the class, for the specified Object.

  • name: String containing the name of the class;
  • properties: Sorted list of the property names of the specified object.

These are the properties we can use for that.

Alert.show(ObjectUtil.getClassInfo(faultEvent.target).name);

Its often useful to know which class had generated some fault event and we can use the above code. 🙂

Happy Coding

Advertisements

%d bloggers like this: