Getting the Class of an object in AS3

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

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

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:

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