Anyone who uses actionscript reflection in non-trivial cases will eventually run into this problem: The is operator only works on instances. For example:
var obj:Object = new Panel();
trace(obj is Panel); //true
trace(obj is UIComponent); //true
trace(obj is Object); //true
trace(obj is IInvalidating); //true
trace(obj is CheckBox); //false
var cls:Class = Panel;
trace(cls is Panel); //false
trace(cls is UIComponent); //false
trace(cls is Object); //true
trace(cls is IInvalidating); //false
trace(cls is CheckBox); //false
This behavior is expected, but not very useful. Since
cls is actually an instance of the Class class, we are actually checking whether the Class class inherits from each of those 5 things. Since Class only extends Object, that’s the only one that’s true.
What happens if you only have a Class object and you need to check if it’s the subclass of another Class?