source:http://blog.3r1c.net/?cat=14
As you can see here, getQualifiedClassName returns the class name of an Actionscript object. According to livedocs (which put it better than I would have): Any ActionScript value may be passed to this method including all available ActionScript types, object instances, primitive types such as uint, and class objects.
Similarly, getQualifiedSuperclassName returns the base class of the value passed to the method, and adhered to the same rules as getQualifiedClassName.
If you want to go backwards and pass in an actual string representation of a class and get a Class object back, you would want to use getDefinitionByName as I used it above.
To me, the most useful of these methods was the last one 'describeType.' I used this primarily to see if classes implement a certain interface. To keep things abstract a lot of times i will have 'clients' of my components simply pass in Classes to be used as itemRenderers, and will then use Adobe's ClassFactory to create as many instances of this as need be. A lot of these times I will want these classes to be obligated to implement methods, so I will want them to implement a certain Interface. Now, using describeType I can very easily check this at runtime without actually instantiating and using the 'is' operator.
These are some great improvements to Actionscript and a sign that it's really starting to 'grow up.'
Tuesday, July 24, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment