Hi,
I thought I understood how typedef
works, but apparently not…
I have this typedef
just under my imports:
typedef Tiles_Datas = {
var type:Int;
var tiles:Array<Tile>;
}
Then, I have this:
class MyClass extends Sprite{
...
private var tiles_up_checked:Tiles_Datas;
private var tiles_down_checked:Tiles_Datas;
private var tiles_left_checked:Tiles_Datas;
private var tiles_right_checked:Tiles_Datas;
...
public function new() {
super();
tiles_up_checked.type = -1;
tiles_down_checked.type = -1;
tiles_left_checked.type = -1;
tiles_right_checked.type = -1;
}
}
When I lauch the program, it gives me an error at the first line where I try to set the type at -1.
Uncaught exception - Invalid field access
How should I use Typedef
? Or maybe I should create a private class just under my main class in the same file instead of Typedef
?
Thank you for your help!