Record the implementation of the as3 reflection function

Source: Internet
Author: User

Reprinted Please note: http://blog.csdn.net/herm_lib/article/details/8500005

The reflection function of as3 was previously done. After a short time, I forgot to check the previous code. Record him this time.

Reflection function:

Objects of this type can be generated based on the Type name; or

A new object is generated based on a type of object, which is the concept of prototype.

Static languages such as C ++ require external support for reflection, because the language type itself does not support complete runtime type information. The as3 language supports such features.

In as3, reflection can be achieved through describetype (OBJ: Object) and getdefinitionbyname (Name: string.

1. Get Object Name

If our application already knows the object name, this step is not required.

VaR XML: xml = describetype (data); objname = xml. @ name;

2. generate an object by name

VaR objclass: class = getdefinitionbyname (objname) as class; var OBJ: Object = new objclass ();

Reflection can be achieved at most in the above two steps.

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.