Abstract class property question

error vector.AVector3 has no field x?



how to fixed that?

extern class Vector3 {

    function new(?x:Float, ?y:Float, ?z:Float);

    var x : Float;

    var y : Float;

    var z : Float;
package ;

abstract AVector3<T>(Vector3) from Vector3 to Vector3 {

    public function new(s) {

        this = s;




here my test code

	var vector:AVector3<Float> = new AVector3<Float>(new Vector3());
        var xx=vector.x;//will error:

I try to add some meta like @:nativeGen @:nativeProperty ,but not work.

is that mean I have to add this extra function to get x? it seem very ugly.

public inline function asType():Vector3 {

        return cast this;


Just add @:forward metadata to AVector3.
Cf. Forwarding abstract fields - Haxe - The Cross-platform Toolkit

1 Like