views:

70

answers:

2

Given that both of these calls to getQualifiedClassName return the same thing (mx:Label), how would one go about programatically differentiating between an instance of a class and a reference to the class...

    var lab1:Label=new Label();
    var lab2:Class=Label;
    var qcn1:String=getQualifiedClassName(lab1);
    var qcn2:String=getQualifiedClassName(lab2);

In other words, how could I know that lab1 is of type Label, while lab2 is type "Class".

typeof() simply returns "object" for both... getQualifiedClassName returns "mx.controls::Label" for both...

What do I use?

+7  A: 

The is operator:

>>> lab1 is Label
true
>>> lab1 is Class
false
>>> lab2 is Label
false
>>> lab2 is Class
true

Also (although this should be trivially true) lab2 == Label.

David Wolever
A: 

trace( Sprite is Class ); // true
trace( new Sprite() is Class ); // false

valyard