enum Color { red; green; blue; } class Colors { static function toInt( c : Color ) : Int { return switch( c ) { case red: 0xFF0000; case green: 0x00FF00; case blue: 0x0000FF; } } } enum Color2 { red; green; blue; grey( v : Int ); rgb( r : Int, g : Int, b : Int ); } class Colors { static function toInt( c : Color3 ) : Int { return switch( c ) { case red: 0xFF0000; case green: 0x00FF00; case blue: 0x0000FF; case grey(v): (v << 16) | (v << 8) | v; case rgb(r,g,b): (r << 16) | (g << 8) | b; case alpha(a,c): (a << 24) | (toInt(c) & 0xFFFFFF); } } }