Object introspection in Flex


Object introspection  is really a very nice feature provided by Adobe in Flex. With the help of introspection we can analyse the properties of the object, And this comes very handy when you want to assign some values to these properties. Below is an example on the same.

1. ObjectUtil.toString(buttonObject); is the method which displays all the properties of a given object

2. We can utilise the robust implementation of Flex. By using describe(object:*). This is common API used in Flex automation framework.

var classPropStr:String=””;
var classInfo:XML = describeType(b);
for each(var a:XML in classInfo..accessor){
//no need to get value if write only
if(a.@access == ‘writeOnly’){
trace(“Property “+ a.@name + “(” + a.@type + “)\n”);
trace(“Property “+ a.@name + “=” +b[a.@name] + “(” + a.@type + “)\n”);

This is really a very nice stuff, even we can write some object spy frameworks to introspect the objects on the fly.

R Vashi.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.