Search code examples
reflectionstatichaxe

Haxe Reflection Method to Access a Static Field?


I'm looking for a way to use reflection to get and set static fields of a Class. Is that possible, or is that too dynamic for Haxe?


Solution

  • You mean, if it's too static for Reflection :)? No, it is not

    var cl = Type.resolveClass("MyClass");
    trace(Reflect.fields(cl));
    trace(Reflect.field(cl, "field"));
    trace(Reflect.setField(cl, "field", 0));