I want to implement this method
function isInstance(a:Class, b:Class):Boolean;
This is how AS3 work with Classes. Note that MovieClip extends Sprite.
trace(MovieClip is Sprite); // false
trace(Sprite is MovieClip); // false
trace(Sprite is Sprite); // false
trace(Sprite is Object); // true
I been trying the next code but it is not working:
/**
* return if instance of class 'a' can be cast to instant of class 'b'
*/
private function isInstance(a:Class, b:Class):Boolean{
var superclass:Class = a;
do {
if (superclass == b) {
return true;
}
superclass = getSuperClass(a);
} while (superclass != null);
return false;
}
private function getSuperClass(claz:Class):Class{
var qualifiedSuperclassName:String = getQualifiedSuperclassName(claz);
var returnValue:Class = getDefinitionByName(qualifiedSuperclassName) as Class;
return returnValue;
}