Using XML and ActionScript with Flex Applications - Reflection
(Page 4 of 5 )
ActionScript 3.0 supports class reflection using the following functions in the flash.utils package:
flash.utils package:ActionScript 3.0 supports class reflection using the following functions in the flash.utils package:
- getQualifiedClassName
- getQualifiedSuperclassName
- getDefinitionByName
- describeType
We’ll next discuss each of these functions in more detail.
Getting the Class Name
You can retrieve the name of the class for which an object is an instance using the getQualifiedClassName() function. The function requires that you pass it a reference to an object; it then returns the fully qualified class name:
var loader:URLLoader = new URLLoader();
var className:String = getQualifiedClassName(loader);
trace(className); // Displays flash.net.URLLoader
If you want to retrieve the fully qualified superclass name for an object, you can use thegetQualifiedSuperclassName()function:
var loader:URLLoader = new URLLoader();
var className:String = getQualifiedSuperclassName(loader);
trace(className); // Displays flash.events.EventDispatcher
Next: Getting the Class by Name >>
More Flash Articles
More By O'Reilly Media
|
This article is excerpted from chapter four of the book Programming Flex 2, written by Chafic Kazoun and Joey Lott (O'Reilly, 2007; ISBN: 059652689X). Check it out today at your favorite bookstore. Buy this book now.
|
|