Reflection (shorthand) analysis in AS3 _flash AS3

Source: Internet
Author: User
Tags reflection


Class Name: Passes an object, returns the full name of the class

var loader:urlloader = new Urlloader ();
var classname:string = getqualifiedclassname (loader);
Trace (ClassName); Displays Flash.net.URLLoader

Class name of the parent class: Passing an object, returning the class name of the parent class

var loader:urlloader = new Urlloader ();
var classname:string = getqualifiedsuperclassname (loader);
Trace (ClassName); Displays Flash.events.EventDispatcher

Class by class name

var classreference:class = Class (Getdefinitionbyname ("Flash.net.URLLoader"));
Once you've got a reference to the class, you can do it.
var instance:object = new Classreference ();

Examples of getqualifiedclassname () or getqualifiedsuperclassname () in combination with Getdefinitionbyname ():

var loader:urlloader = new Urlloader ();
var classname:string = getqualifiedclassname (loader);
var classreference:class = Class (Getdefinitionbyname (className));
var instance:object = new Classreference ();

Introspection:describetype () returns the type description of the object

For example:

var loader:urlloader = new Urlloader ();
var description:xml = describetype (loader);
Trace (description);

Output:

<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"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.