onrails.org home

Flex introspection API: describeType(value:*):XML

I am playing with the mx.automation framework provided by Flex. For that I need to associate each control with it’s automation implementation. More on that on a subsequent blog entry. But it some case I need to find the super class of a class

Let’s take the following three classes:

class A {}
class B extends A {}
class Tab extends Button {}

Now we can create the following function:

import flash.utils.describeType;
private function superClass(clazz:Class):String {
return describeType(clazz).factory.extendsClass0.@type;

Let run the following code

trace(“A super class:”superClass(A));
trace(“B super class:”
trace(“Tab super class:”+superClass(Tab));

And we get the following output:

A super class:Object
B super class:com.nouvelles_solutions::A
Tab super class:mx.controls::Button

Let me know if there is an easier way.

The build in describeType function takes a class as parameter and return an XML definition of a class. For example describeType(B) returns the following:

Pretty cool.

Fork me on GitHub