b2DistanceJoint question

Hi Everybody!!

It is my first project with Box2d. Everything works perfect, but I have one problem with b2DistanceJoint. It looks really strange.

I am creating joint in this code:
Code:
public function addJoint(b1, b2: b2Body, xy1, xy2: b2Vec2): void{
  var jointDef: b2DistanceJointDef = new b2DistanceJointDef();
  jointDef.Initialize(b1, b2, xy1, xy2);
  jointDef.collideConnected = true;
  m_world.CreateJoint(jointDef);
}


I create some boxes an connect them with b2DistanceJoint in this function. Everything works ok when I first pass small box and next horizontal box (green on screen). When I pass boxes in diferrent order small box starts to behave strange. It sticks to other objects or even push them (box marked with arrow should hang straight down, but it moves left). Maybe anyone had simillar problems?

I know, that maybe it is problem caused by other parts of my code...

I am using version: Version 2.0.0

Here is screenshot of my application.
Image
I have written small test application. It looks like bug, but maybe I am doing something wrong.

Left objects are created in simillar way like right objects, but are passed to b2DistanceJoint in different order.
Thank you for the bug report. I believe I have fixed the bug in Box2D Flash 2.0.1, available at the usual link:
http://deleongames.com/nesky/Box2DFlashAS3_2_0_1.zip

If you'd prefer to stick to 2.0.0, you can replace lines 79 through 81 in Box2D/Dynamics/Joints/b2DistanceJoint.as with the following code:
Code:
      //m_u = b2->m_sweep.c + r2 - b1->m_sweep.c - r1;
      m_u.x = b2.m_sweep.c.x + r2X - b1.m_sweep.c.x - r1X;
      m_u.y = b2.m_sweep.c.y + r2Y - b1.m_sweep.c.y - r1Y;
The r1 was present in the C++ version, but was missing from the AS3 version.
Thank you very much 🙂.

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