• AS3的反射


    详细了解AS3的反射,请google相关文章,这里只是速记一下

    取类名: 传进一个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"/>
  • 相关阅读:
    Java String 乱码
    HBase非原理性浅析
    git cherry-pick
    数据结构之队列
    数据结构之栈
    算法之简单排序
    数据结构之数组
    数据结构简介
    Java类型信息
    基数排序
  • 原文地址:https://www.cnblogs.com/klh5211314/p/3345767.html
Copyright © 2020-2023  润新知