GearJoint issue

Sorry for my english first...

I have problem with creating new GearJoint in my project.
I have two bodyes (body1 and body2), which are connected with GroundBody with help of RevoluteJoint (joint1 and joint2)
I need to constantly rotate first body with help of joint1 motor.
I want to connect joint1 and joint2 with GearJoint, to rotate the second body too.
I create joint, no errors, etc., but second body stay immobile.

Can it caused using of 2.1a version ?
What I do wrong ?

some of the code here:

Code: Select all

            var jointGearDef:b2GearJointDef = new b2GearJointDef();
            jointGearDef.bodyA = body1;
            jointGearDef.bodyB = body2;
            jointGearDef.joint1 = joint2;
            jointGearDef.joint2 = joint1;
            jointGearDef.ratio = 1;
            var gearJoint:b2GearJoint = world.CreateJoint(jointGearDef) as b2GearJoint;

full code here:
Main
class World

I use the CodeDrive IDE (box2D tests works OK, so I'd not think it issue caused by IDE).
Here is a Warning thing in the Box2D as3 API documentation concerning b2GearJoints:

"Warning: The revolute and prismatic joints must be attached to fixed bodies (which must be body1 on those joints)."

That might be the problemt.
jayther wrote:Here is a Warning thing in the Box2D as3 API documentation concerning b2GearJoints:

"Warning: The revolute and prismatic joints must be attached to fixed bodies (which must be body1 on those joints)."

That might be the problemt.

Thanks for the answer, but I already found the solution:
Instead of manualy initialization of revolute joint definition:

Code: Select all

            var jointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
            jointDef.bodyA = body1;
            jointDef.bodyB = world.GetGroundBody();
            jointDef.localAnchorA = new b2Vec2(0,0);
            jointDef.localAnchorB = new b2Vec2(3,3);
            // ...

I use .Initialize() method:

Code: Select all

            var jointDef:b2RevoluteJointDef = new b2RevoluteJointDef();
            jointDef.Initialize(world.GetGroundBody(), body1, body1.position);
            //...

and now it works OK. I guess, it's bug of Alpha version.

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