How to use Vector with offset from parent Haxe class instance?

Viewed 96

What methods are available to achieve accessing parent instance Vector cell from another class?

My question is about the lines commented with "??":

class Test {
    static function main() {
        var a:A = new A();
        var b:B = new B(a, 115);
    }
}

class A {
    public var cells:haxe.ds.Vector<Float>;

    public function new() {
        cells = new haxe.ds.Vector(1000);
    }
}

class B {
    public var a:A; // the "parent"
    public var my_offset:Int;
    public var my_cells:haxe.ds.Vector<Float>; //??

    public function new(a:A, offset:Int) {
        my_offset = offset;
        my_cells[2] = 0.5; //?? actually a.cells[my_offset + 2];
    }

}

Is it possible to:

  • access parent Vector memory directly?
  • use a macro?
  • use an abstract?

"Try Haxe" link

1 Answers
Related