Quantcast
Channel: MarsHut
Viewing all articles
Browse latest Browse all 6551

Problem with 'Array of Class' as member of 'Array of Class'

$
0
0
Hello everybody, I'm new in the forum and with Haxe... I have a lot of
questions... I'll start with this one.

The example code:
class Main

static function main()

new Main();

function new()

var plc: Array<PLC> = [];
plc[1] = new PLC(); //<--- Null Array Reference
trace(plc[1].name);
trace(plc[1].tag[1].name);

class PLC

public var name: String;
public var tag: Array<PlcTag>;

public function new()

this.name = "Plc test name";
tag[1] = new PlcTag();

class PlcTag

public var name: String;

public function new()

this.name = "Tag test name";

It compiles, but I get a "Critical Error: Null Array Reference" when I
execute. I need to create an Array as a member of another Array. Is it
possible?
Thank you.

Viewing all articles
Browse latest Browse all 6551

Trending Articles