B2dFlash 2.02 : Bug after recreating the level

hello, sometimes i have this error when i recreate the level.
Quote:
RangeError: Error #1005: L'index du tableau n'est pas un entier positif (-1).
at Error$/throwError()
at Array()
at Box2D.Dynamics::b2Island()[C:\Program Files\_travail\xampp\htdocs\_progFlash\_flashdevelop\jeux1b\src\Box2D\Dynamics\b2Island.as:141]



the solution i found for this bug is to add this line :
Code:
jointCapacity = jointCapacity < 0 ? 0 : jointCapacity;

before :
Code:
      m_joints = new Array(jointCapacity);
      for (i = 0; i < jointCapacity; i++)
         m_joints[i] = null;


my solution is good ?
why this bug ?
maybe the use of int instead uint for initialize a array is not very smart
You are fixing the symptom not the problem. Several others have reported this error, though i'm not sure from what. Double deleting an object seems the most likely problem.
hello Boris

so i made something wrong while using B2dFlash 🙁

ok, i will had some security when deleting b2body


thank's for the answer.
now i put all the body et joint in array for deleting them properly and i have a new error (always after recreating 8 times the same level) ... it's again in b2Island, it's again the same error, but now it's the line 141 :

Code:
      m_bodies = new Array(bodyCapacity);
      for (i = 0; i < bodyCapacity; i++)
         m_bodies[i] = null;


Quote:
RangeError: Error #1005: L'index du tableau n'est pas un entier positif (-1).
at Error$/throwError()
at Array()
at Box2D.Dynamics::b2Island()[C:\Program Files\_travail\xampp\htdocs\_progFlash\_flashdevelop\jeux1b\src\Box2D\Dynamics\b2Island.as:131]
at Box2D.Dynamics::b2World/Solve()[C:\Program Files\_travail\xampp\htdocs\_progFlash\_flashdevelop\jeux1b\src\Box2D\Dynamics\b2World.as:495]
at Box2D.Dynamics::b2World/Step()[C:\Program Files\_travail\xampp\htdocs\_progFlash\_flashdevelop\jeux1b\src\Box2D\Dynamics\b2World.as:429]



maybe it's not a bug, it's Easter egg and Boris want us to find all 😀
I don't know about that!
If you could make a packaged example demonstrating it is still a problem with the current SVN version, I'll look into it. Otherwise, I don't consider 2.0 to be sufficiently important now for bugfixes. I'd still be interested if you figure out the problem.
sorry but i can't use the new versions, because all my class are set for 2.02.
i had try to migrate to the new (2.1a) but i have too much change to support this version, maybe in the future.

thank's
Well, there's always the obvious workaround of deleting the world rather than emptying it. I usually do that anyway, it's easier.

Original thread: https://box2d.org/forum/viewtopic.php?t=4816