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 ];
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 ];
使用 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"));
}