Closed bartvanheukelom closed 10 years ago
This has nothing to do with a Space being constructed or not, this is to do with constructing objects during a static __init__
which runs 'really' early during boot time, before anything else is initialised (in this case the id counter for CbType itself)
I've tried finding where the id counter is initialised but couldn't find it due to (presumably) a lack of Caxe knowledge. However, could it not be initialised in a static __init__
also?
Never mind, I've found that one can simply use public static var CBTYPE = new CbType();
. I hadn't tried because previously when I tried something similar Haxe had complained that field initialisation should be a constant expression. However, it works, and is apparently executed later than __init__
.
Sorry, kinda new to Haxe :*)
Edit: Yeah, I should have RTFM: "Then, all static function init method body code is generated. [...] static variables have not yet been initialized; these functions should only be used to perform very low level initializations.". I ass-umed they worked like Java's static {}
blocks.
A CbType that is constructed before a Space is constructed will have
id = NaN
and not function properly in callbacks. This adds inconvenience because you can't use a construct like this: