AS3.0反射机制的使用


取类名: 传进一个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( )返回对象的类型描述

你可能感兴趣的:(.net,Flash)