It is worth noting that XML objects (XML, XMLList) are an exception to this (i.e. (new XML () as Object) .constructor as class == null). I recommend abandoning getDefinitionByName (getQualifiedClassName) when the constructor does not solve:
function getClass(obj : Object) : Class { var cls : Class = (obj as Class) || (obj.constructor as Class); if (cls == null) { cls = getDefinitionByName(getQualifiedClassName(obj)); } return cls; }
Note that getDefinitionByName throws an error if the class is defined in another (including child) application domain from the calling code.
Richard Szalay Jan 23 '09 at 8:58 2009-01-23 08:58
source share