static public const CONST_1 :String = "CONST_1";
static public const CONST_A :String = "CONST_A";
public var constantsArr :Array;
是否可以获取类常量值的数组,而无需像下面这样手动添加它们:
constantsArr = [ CONST_1, CONST_A ];
答案 0 :(得分:14)
使用describeType应该是可能的:
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"));
}