I've been trying to write a function to create a simple circle in Box2DFlash . but it keeps telling me that the object is null and I can't access it's properties here's the code:
public var f1:b2Body;
public var f2:b2Body;
public function addACrate(fallingCrate:b2Body, positionX:Number,positionY:Number):void
{
var fallingBodyDef:b2BodyDef = new b2BodyDef();
fallingBodyDef.type = b2Body.b2_dynamicBody;
fallingBodyDef.position.Set(positionX/ratio,positionY/ratio);
fallingCrate =_world.CreateBody(fallingBodyDef);
var fallingCrateShape:b2CircleShape = new b2CircleShape();
fallingCrateShape.SetRadius(10/ratio);
var fixtureDef:b2FixtureDef = new b2FixtureDef();
fixtureDef.shape = fallingCrateShape;
fixtureDef.density = 0.7;
fixtureDef.friction = 0.5;
fixtureDef.restitution = 0.3;//bouncyness
fallingCrate.CreateFixture(fixtureDef);
}
addACrate(f1,270,0);
trace(f1.GetPosition().y);
and when I try to access the "y" property of my "f1" object it tells me that it's null . I'll be appreciated if someone can tell me what's wrong
thanks