How to cast int to Enum?

How to cast int to Enum?

there are no api in Type.hx,only

public static function createEnum( e : Enum, constr : String, ?params : Array ) : T;

public static function createEnumIndex( e : Enum, index : Int, ?params : Array ) : T;

my enum look like :slight_smile:

@:enum
abstract EnumGameEvent(Int) {
var SUB_C_PLACE_JETTON = 1;
var SUB_C_APPLY_BANKER = 2;
var SUB_C_CANCEL_BANKER = 3;
var SUB_C_CONTINUE_CARD = 4;
var SUB_C_AMDIN_COMMAND = 5;
}

2 Likes

add from Int to the abstract

@Jarrio ,thank you reply .
can you give me more tip about

how to dd from Int to the abstract?

@Jarrio

abstract EnumGameEvent(Int) from Int

thanks ,it’s work use from Int to Int