代码
//================类名: 传进一个object,返回类的全名
var loader:URLLoader = new URLLoader( );
var className:String = getQualifiedClassName(loader);
trace(className); // Displays flash.net.URLLoader
//================取父类的类名:传进一个object,返回父类的类名
var loader:URLLoader = new URLLoader( );
var className:String = getQualifiedSuperclassName(loader);
trace(className); // Displays flash.events.EventDispatcher
//================根据类名取类
var classReference:Class = Class(getDefinitionByName("flash.net.URLLoader"));
//一但你得到了类的引用后,就可以这样
var instance:Object = new classReference( );
//================getQualifiedClassName( ) 或 getQualifiedSuperclassName( ) 与 getDefinitionByName() 结合使用的例子:
var loader:URLLoader = new URLLoader( );
var className:String = getQualifiedClassName(loader);
var classReference:Class = Class(getDefinitionByName(className));
var instance:Object = new classReference( );
//================Introspection:describeType( )返回对象的类型描述
//例如:
var loader:URLLoader = new URLLoader( );
var description:XML = describeType(loader);
trace(description);
/*
输出:
<type name="flash.net::URLLoader" base="flash.events::EventDispatcher"
isDynamic="false" isFinal="false" isStatic="false">
<metadata name="Event">
<arg key="name" value="httpStatus"/>
<arg key="type" value="flash.events.HTTPStatusEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="securityError"/>
<arg key="type" value="flash.events.SecurityErrorEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="ioError"/>
<arg key="type" value="flash.events.IOErrorEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="progress"/>
<arg key="type" value="flash.events.ProgressEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="complete"/>
<arg key="type" value="flash.events.Event"/>
</metadata>
<metadata name="Event">
<arg key="name" value="open"/>
<arg key="type" value="flash.events.Event"/>
</metadata>
<extendsClass type="flash.events::EventDispatcher"/>
<extendsClass type="Object"/>
<implementsInterface type="flash.events::IEventDispatcher"/>
<constructor>
<parameter index="1" type="flash.net::URLRequest" optional="true"/>
</constructor>
<variable name="bytesTotal" type="uint"/>
<variable name="data" type="*"/>
<method name="load" declaredBy="flash.net::URLLoader" returnType="void">
<parameter index="1" type="flash.net::URLRequest" optional="false"/>
</method>
<method name="close" declaredBy="flash.net::URLLoader" returnType="void"/>
<variable name="dataFormat" type="String"/>
<variable name="bytesLoaded" type="uint"/>
<method name="dispatchEvent" declaredBy="flash.events::EventDispatcher"
returnType="Boolean">
<parameter index="1" type="flash.events::Event" optional="false"/>
</method>
<method name="toString" declaredBy="flash.events::EventDispatcher"
returnType="String"/>
*/
var loader:URLLoader = new URLLoader( );
var className:String = getQualifiedClassName(loader);
trace(className); // Displays flash.net.URLLoader
//================取父类的类名:传进一个object,返回父类的类名
var loader:URLLoader = new URLLoader( );
var className:String = getQualifiedSuperclassName(loader);
trace(className); // Displays flash.events.EventDispatcher
//================根据类名取类
var classReference:Class = Class(getDefinitionByName("flash.net.URLLoader"));
//一但你得到了类的引用后,就可以这样
var instance:Object = new classReference( );
//================getQualifiedClassName( ) 或 getQualifiedSuperclassName( ) 与 getDefinitionByName() 结合使用的例子:
var loader:URLLoader = new URLLoader( );
var className:String = getQualifiedClassName(loader);
var classReference:Class = Class(getDefinitionByName(className));
var instance:Object = new classReference( );
//================Introspection:describeType( )返回对象的类型描述
//例如:
var loader:URLLoader = new URLLoader( );
var description:XML = describeType(loader);
trace(description);
/*
输出:
<type name="flash.net::URLLoader" base="flash.events::EventDispatcher"
isDynamic="false" isFinal="false" isStatic="false">
<metadata name="Event">
<arg key="name" value="httpStatus"/>
<arg key="type" value="flash.events.HTTPStatusEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="securityError"/>
<arg key="type" value="flash.events.SecurityErrorEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="ioError"/>
<arg key="type" value="flash.events.IOErrorEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="progress"/>
<arg key="type" value="flash.events.ProgressEvent"/>
</metadata>
<metadata name="Event">
<arg key="name" value="complete"/>
<arg key="type" value="flash.events.Event"/>
</metadata>
<metadata name="Event">
<arg key="name" value="open"/>
<arg key="type" value="flash.events.Event"/>
</metadata>
<extendsClass type="flash.events::EventDispatcher"/>
<extendsClass type="Object"/>
<implementsInterface type="flash.events::IEventDispatcher"/>
<constructor>
<parameter index="1" type="flash.net::URLRequest" optional="true"/>
</constructor>
<variable name="bytesTotal" type="uint"/>
<variable name="data" type="*"/>
<method name="load" declaredBy="flash.net::URLLoader" returnType="void">
<parameter index="1" type="flash.net::URLRequest" optional="false"/>
</method>
<method name="close" declaredBy="flash.net::URLLoader" returnType="void"/>
<variable name="dataFormat" type="String"/>
<variable name="bytesLoaded" type="uint"/>
<method name="dispatchEvent" declaredBy="flash.events::EventDispatcher"
returnType="Boolean">
<parameter index="1" type="flash.events::Event" optional="false"/>
</method>
<method name="toString" declaredBy="flash.events::EventDispatcher"
returnType="String"/>
*/