AS3 - How can I get an array of class constants?

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 class constant values ​​without manually adding them as follows:

  constantsArr = [ CONST_1, CONST_A ]; 
+6
source share
1 answer

Using describeType 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")); } 
+14
source

Source: https://habr.com/ru/post/921046/


All Articles