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.