Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between Class Reference And Class Instance

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?

like image 543
Joshua Avatar asked Mar 20 '26 19:03

Joshua


2 Answers

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.

like image 117
David Wolever Avatar answered Mar 23 '26 11:03

David Wolever


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

like image 32
Valentin Simonov Avatar answered Mar 23 '26 10:03

Valentin Simonov