static public const CONST_1 :String = "CONST_1";
static public const CONST_A :String = "CONST_A";
public var constantsArr :Array;
Is it possible to get an array of the class constant values without adding them manually like this:
constantsArr = [ CONST_1, CONST_A ];
Using describeType it should be possible :
public class Constants
{
static public const CONST_1 :String = "CONST_1";
static public const CONST_A :String = "CONST_A";
}
var xmlList:XMLList = describeType(Constants).child("constant");
var constantsArray:Array = [];
for each(var key:XML in xmlList)
{
constantsArray.push(key.attribute("name"));
}
来源:https://stackoverflow.com/questions/11596475/as3-how-can-i-get-an-array-of-constants-of-a-class