How to check if two objects are of the same type in Actionscript?

Simon_Weaver picture Simon_Weaver · Nov 22, 2008 · Viewed 19.4k times · Source

I want to do this in Actionscript:

typeof(control1) != typeof(control2)

to test if two objects are of the same type. This would work just fine in C#, but in Actionscript it doesnt. In fact it returns 'object' for both typeof() expressions because thats the way Actionscript works.

I couldn't seem to find an alternative by looking in the debugger, or on pages that describe typeof() in Actionscript.

Is there a way to get the actual runtime type?

Answer

Marcus Blankenship picture Marcus Blankenship · Nov 24, 2008

The best way is to use flash.utils.getQualifiedClassName(). Additionally, you can use flash.utils.describeType() to get an XML document the describes more about the class.