Created
October 5, 2014 13:22
-
-
Save MindScriptAct/fbe9848e72603b57fb43 to your computer and use it in GitHub Desktop.
Enum for as3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils.types { | |
import flash.utils.describeType; | |
public class Enum { | |
// USAGE: | |
//package myProject.constants { | |
//import utils.types.Enum; | |
//public class ScreenIdEnum { | |
// {Enum.init(ScreenIdEnum);} | |
// public static const START:Enum = new Enum(); | |
//}} | |
public var enumName:String = "Add '{Enum.initEnumConstants(<class>);}' to you Enum class." | |
public function toString():String { | |
return enumName; | |
} | |
public static function init(enumClass:Class):void { | |
var type:XML = describeType(enumClass); | |
for each (var constant:XML in type.constant) { | |
enumClass[constant.@name].enumName = constant.@name; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment