Reflecting actionscript objects
Is it possible to reflect an object in actionscript and get the property names back in the order they are positioned in the class? I have tried the following
var reflectionO开发者_如何学运维bject : Object = ObjectUtil.getClassInfo(obj);
var propsArray : Array = reflectionObject.properties;
(orders alphabetically)
var typeInfo:XML = describeType(obj)
(Not sure what order this is)
There is little ways of reflecting an object in AS3, but all of them are mentioned on this site.
Both of your ways are correct.
Other ways of doing so include, but are not limited the following, according to insideria:
Accessors (Getters/Setters)
var accessors:XMLList = classAsXML.accessor; trace("accessors", accessors.length(), accessors);
Properties
var variables:XMLList = classAsXML.variable; trace("variables", variables.length(), variables);
EDIT: I have revised my answer and I have found the following site that adds up some details about reflection.
EDIT 2: I knew I forgot something here. What jonathanasdf said in his comment is true: there is no way to get the properties in the order defined in a said class.
精彩评论