取类名:传进一个object,返回类的全名
varloader:URLLoader=newURLLoader();
varclassName:String=getQualifiedClassName(loader);
trace(className);//Displaysflash.net.URLLoader
取父类的类名:传进一个object,返回父类的类名
varloader:URLLoader=newURLLoader();
varclassName:String=getQualifiedSuperclassName(loader);
trace(className);//Displaysflash.events.EventDispatcher
根据类名取类
varclassReference:Class=Class(getDefinitionByName("flash.net.URLLoader"));
//一但你得到了类的引用后,就可以这样
varinstance:Object=newclassReference();
getQualifiedClassName()或getQualifiedSuperclassName()与getDefinitionByName()结合使用的例子:
varloader:URLLoader=newURLLoader();
varclassName:String=getQualifiedClassName(loader);
varclassReference:Class=Class(getDefinitionByName(className));
varinstance:Object=newclassReference();
Introspection:describeType()返回对象的类型描述
例如:
varloader:URLLoader=newURLLoader();
vardescription:XML=describeType(loader);
trace(description);
输出:
<typename="flash.net::URLLoader"base="flash.events::EventDispatcher"
isDynamic="false"isFinal="false"isStatic="false">
<metadataname="Event">
<argkey="name"value="httpStatus"/>
<argkey="type"value="flash.events.HTTPStatusEvent"/>
</metadata>
<metadataname="Event">
<argkey="name"value="securityError"/>
<argkey="type"value="flash.events.SecurityErrorEvent"/>
</metadata>
<metadataname="Event">
<argkey="name"value="ioError"/>
<argkey="type"value="flash.events.IOErrorEvent"/>
</metadata>
<metadataname="Event">
<argkey="name"value="progress"/>
<argkey="type"value="flash.events.ProgressEvent"/>
</metadata>
<metadataname="Event">
<argkey="name"value="complete"/>
<argkey="type"value="flash.events.Event"/>
</metadata>
<metadataname="Event">
<argkey="name"value="open"/>
<argkey="type"value="flash.events.Event"/>
</metadata>
<extendsClasstype="flash.events::EventDispatcher"/>
<extendsClasstype="Object"/>
<implementsInterfacetype="flash.events::IEventDispatcher"/>
<constructor>
<parameterindex="1"type="flash.net::URLRequest"optional="true"/>
</constructor>
<variablename="bytesTotal"type="uint"/>
<variablename="data"type="*"/>
<methodname="load"declaredBy="flash.net::URLLoader"returnType="void">
<parameterindex="1"type="flash.net::URLRequest"optional="false"/>
</method>
<methodname="close"declaredBy="flash.net::URLLoader"returnType="void"/>
<variablename="dataFormat"type="String"/>
<variablename="bytesLoaded"type="uint"/>
<methodname="dispatchEvent"declaredBy="flash.events::EventDispatcher"
returnType="Boolean">
<parameterindex="1"type="flash.events::Event"optional="false"/>
</method>
<methodname="toString"declaredBy="flash.events::EventDispatcher"
returnType="String"/>