Hi guys, I'm working through Emmanuel Ferranto's book Box2DForFlashGames and I'm stumped on something that seems like it should not be a problem.
Im making a distance joint between two blocks that can be dragged by the mouse.
Here's the code:
Here's my error:
the error is thrown for this line:
If I comment out this line everything goes right along.
The locals panel shows bodyA as undefined, bodyB as undefined and edge as null. I don't know if these are important or not but its the only thing I could find.
Any body have any clues?????
Im making a distance joint between two blocks that can be dragged by the mouse.
Here's the code:
Code: Select all
var groundBody:b2Body = world.CreateBody(bodyDef);
groundBody.CreateFixture(fixtureDef);
bodyDef.position.Set(320 / worldScale, 430 / worldScale);
bodyDef.type = b2Body.b2_dynamicBody;
polygonShape.SetAsBox(30 / worldScale, 30 / worldScale);
fixtureDef.density = 1;
fixtureDef.friction = .4;
fixtureDef.restitution = .2;
var box2:b2Body = world.CreateBody(bodyDef);
box2.CreateFixture(fixtureDef);
bodyDef.position.Set(420 / worldScale, 430 / worldScale);
var box3:b2Body = world.CreateBody(bodyDef);
box3.CreateFixture(fixtureDef);
var dJointDef:b2DistanceJointDef = new b2DistanceJointDef();
dJointDef.bodyA = box2;
dJointDef.bodyA = box3;
dJointDef.localAnchorA = new b2Vec2(0, 0);
dJointDef.localAnchorB = new b2Vec2(0, 0);
dJointDef.length = 100 / worldScale;
var distanceJoint:b2DistanceJoint;
distanceJoint = world.CreateJoint(dJointDef ) as b2DistanceJoint;
Here's my error:
[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.
the error is thrown for this line:
Code: Select all
distanceJoint = world.CreateJoint(dJointDef ) as b2DistanceJoint;
If I comment out this line everything goes right along.
The locals panel shows bodyA as undefined, bodyB as undefined and edge as null. I don't know if these are important or not but its the only thing I could find.
Any body have any clues?????