Getting Class of an Object in Flex

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

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: