AS3: Reflection

Source: Internet
Author: User

Reflection refers to how a program obtains class information during runtime, such as dynamically creating class instances and methods.

See http://bbs.9ria.com/thread-133293-1-1.html
To sum up the usage of as3 reflection, there are four functions:
Flash. system. ApplicationDomain. getDefinition (linkName: String): Class; // The Link name of a component in the flashcs component library.
Flash. utils. getDefinitionByName (name: String): Object; // return Class Object Reference of the class specified by the name parameter
For example, sp: Sprite = new Sprite ();
Flash. display: Sprite: Package path
Flash. utils. getQualifiedClassName (value: *): String; // The fully qualified class name of the returned object.
Flash. utils. getQualifiedSuperClassNameTest; // returns the fully qualified class name of the base class of the object specified by the value parameter.

 

GetDefinitionByName

The usage is as follows::

Obtain the reference of the flash. text. TextField class. The as statement has no exception in type conversion. If the conversion fails, the target variable will be set to null.

Var ClassReference: Class = getDefinitionByName ("com. display. textField ") as Class; var instance: TextField = new ClassReference () as TextField; instance. autoSize = "left"; instance. text = "I use getDefinitionByName to dynamically create ";

 

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.