Getting the Class of an object in AS3_
Nov 04, 2008

A quick and useful titbit: in order to get the class of an object use the following code:

static function getClass(obj:Object):Class {
  return Class(getDefinitionByName(getQualifiedClassName(obj)));
}

This is great for checking the type of an object. For example, if you have an object myObj1 and you want to confirm that it is of the same type as myObj2 you can write:

if (myObj1 is getClass(myObj2)) {
  trace("These objects are of the same class!");
}