1 decade ago by vincentpiel
I noticed a bug that got me crazy for an hour or so.
If you extend a class, and within that class you define a property using another constructor, say : myThing : new Thing(), then it will be a static member for all
instance e.g. firstObject.myThing === anotherObject.myThing.
BUT if you declare it null : myThing : null, then you initialize in the constructor ('init') : this.myThing = new Thing; you now have one 'Thing' per object.
I think this behaviour is misleading, and should at least be notified, but even better corrected. I understand it is most usefull to have sounds, images, ... to be static, but it should not be default behaviour.
If you extend a class, and within that class you define a property using another constructor, say : myThing : new Thing(), then it will be a static member for all
instance e.g. firstObject.myThing === anotherObject.myThing.
BUT if you declare it null : myThing : null, then you initialize in the constructor ('init') : this.myThing = new Thing; you now have one 'Thing' per object.
I think this behaviour is misleading, and should at least be notified, but even better corrected. I understand it is most usefull to have sounds, images, ... to be static, but it should not be default behaviour.