Closed zerobyted closed 7 years ago
That should not be possible, the code you quote should work: either length is zero or non-zero.
Except if you were calling it from two different threads, or (in Flash’s case) two different event handlers at once. If you e.g. have an ENTER_FRAME event that does some processing and a TOUCH event that does more, Flash does nothing to stop them accessing the same data and causing problems like this. The fix is to do all your processing in one event/thread, e.g. the ENTER_FRAME one, and use the TOUCH event handler just to store events which the ENTER_FRAME handler later processes.
I dont call this method. I get "nullpointer" sometimes on tween Sprite3d with Feather's TextInput inside.
Code work fine when both (2d and 3d) pools are empty or full.
3D points pool must be in:
private static var sPoints3D:Vector.<Vector3D> = new <Vector3D>[];
but "getPoint3D(..)" check length of
private static var sPoints:Vector.<Point> = new <Point>[];
Result:
if (sPoints.length > 0 && sPoints3D.length == 0) {
var point:Vector3D = sPoints3D.pop();
point.x = x; // <<< Nullpointer
}
Ah, you're right ... I had to read over the code three times before I saw what you were explaining ... (just as you, John :wink:) that I'm doing the length check on the wrong vector.
Thanks for the report, I'll fix that!
Ah, yes. In both posts I failed to spot the problem, and thought the code fine, hence my reply. Familiar with that sort of bug in my own code: I can stare at it for ages and not spot a problem that is right in front of me.
Haha, yes, I guess that's happening to every developer now and then! :wink:
In any case, it's fixed! Thanks a lot for the bug report!
This method checks sPoints but pop() from sPoints3D. Cause Nullpointer sometimes