Flex: Introspecting An Object By Name

Say you have an object reference in your class:

var button1:Button;

How do you introspect it? One way is to use the Introspection API as described in the Flex 3: Performing Object Introspection doc:

var classInfo:XML = describeType(button1);

But what if you want to use the object name, a string, instead of a class reference? Simply use the ff:

var objectName:String = “button1”;
var objectInfo:XML = describeType(this[objectName]);

From there it’s as simple as going through the XML object as described the rest of the Flex 3 doc.

One Reply to “Flex: Introspecting An Object By Name”

Comments are closed.