Say you’re done introspecting and you want to invoke a method of the object you introspected. Simply use the ff:
var methodName:String = “doSomething”;
var method:Function = object[methodName] as Function;
var returnValue:* = method.apply(object, [“string1”, “string2”]); // or method.call(“string1”, “string2”);
Once caveat, if you’re a Java programmer, you would expect getters and setters to be methods. But in Flex, they’re actually accessors and the above method won’t work. Instead, directly access the attribute by name:
var attributeName:String = “doSomething?;
var returnValue:* = object[attributeName];