rotating shape using your mouse

hello there,

what I want to do is to create one shape that will be rotating with mouse moving
and it works nice.

Code:

   private function createMainBox():void
      {
         
         var _mainBoxDef:b2BodyDef = new b2BodyDef();
         var _mainBoxShape:b2PolygonDef = new b2PolygonDef();
         
         _mainBoxShape.SetAsBox(804 /2 / 30 /3, 354 / 2 / 30 / 3);
         _mainBoxShape.density = .5;
         _mainBoxDef.position.Set(5, 5);
         
         
         
         _mainBox = world.CreateBody(_mainBoxDef);
         _mainBox.CreateShape(_mainBoxShape);
         
         _mainBox.SetMassFromShapes();
      
         
         var pinezkaShape:b2CircleDef = new b2CircleDef();
         var pinezkaDef:b2BodyDef = new b2BodyDef();
         
         
         pinezkaShape.radius = .2;
         pinezkaDef.position.Set( _mainBox.GetWorldCenter().x, _mainBox.GetWorldCenter().y );
         
         
         var pinezkaBody:b2Body = world.CreateBody(pinezkaDef);
         pinezkaBody.CreateShape(pinezkaShape);
         
         pinezkaBody.SetMassFromShapes()
         
         
         var the_rev_joint:b2RevoluteJointDef = new b2RevoluteJointDef();

         the_rev_joint.enableMotor = true;
         the_rev_joint.enableLimit = true;
         

         the_rev_joint.Initialize(_mainBox, pinezkaBody, pinezkaBody.GetWorldCenter());
         var joint_added:b2RevoluteJoint = world.CreateJoint(the_rev_joint) as b2RevoluteJoint;
         
         
      }


      private function loop(e:Event):void
      {

         var rotation:Number =   ((mouseX - (stage.stageWidth / 2)) / 20) / (180/Math.PI)
         
         _mainBox.SetXForm( _mainBox.GetPosition(), rotation );
         

}


but then I want to connect another shape(with distance joint)
and it stops rotating

Code:
   private function createHeroGi():void
      {
         var _giBoxDef:b2BodyDef = new b2BodyDef();
         var _giBoxShape:b2PolygonDef = new b2PolygonDef();
         
         _giBoxShape.density = .5;
         _giBoxShape.SetAsBox(139 / 2 / 30 / 3, 239 / 2 / 30 / 3);
         _giBoxDef.position.Set(_mainBox.GetWorldCenter().x - 13.4 / 3, 6);
         
         _giBox = world.CreateBody(_giBoxDef);
         _giBox.CreateShape(_giBoxShape);
         
         _giBox.SetMassFromShapes();
         
         var distanceJointDef:b2DistanceJointDef = new b2DistanceJointDef();
         distanceJointDef.Initialize(_mainBox, _giBox, new b2Vec2(_mainBox.GetWorldCenter().x-13.4 / 3, _mainBox.GetWorldCenter().y+5.9 / 3),new b2Vec2(_giBox.GetWorldCenter().x, _giBox.GetWorldCenter().y));
         distanceJointDef.collideConnected = true;
         distanceJointDef.length = 3;
         var distanceJoint:b2DistanceJoint = world.CreateJoint(distanceJointDef) as b2DistanceJoint;
         
   
      }



Image



while changing

Code:

         the_rev_joint.enableMotor = true;
         the_rev_joint.enableLimit = true;


to false, strange things happening..
do you have any idea?

cheers

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