Create joints dynamically doesn't manage to work

Hi guys.

I'm new to box2d and wck, but I found it very good to use.
I'm working on a project where I add bubbles to the world, what works perfectly, but when I want to add joints to each bubble than I can't figure out how to do that.
This code doesn't work as I expected:
Code:
var joint:Joint = new BubbleJoint();
joint.connectorClassName = "Connectline";
joint.type = "Distance";
joint.target1Object = newBubble; // newly created Bubble BodyShape
joint.target2Object = MLM_WORLD.B1; // old Bubble BodyShape
Util.addChildAbove(joint, newBubble);
joint.create();

The result is the bubble is sticked to the position where it has been created.
I tried to give all different parameters to the target1Object and target2Object, but none of them works.
On the other hand this code works perfectly:
Code:
var distanceJointDef:b2DistanceJointDef = new b2DistanceJointDef(); 
distanceJointDef.Initialize(newBubble.b2body, MLM_WORLD.B1.b2body,
   newBubble.b2body.GetWorldCenter(), MLM_WORLD.B1.b2body.GetWorldCenter());
MLM_WORLD.b2world.CreateJoint(distanceJointDef);


Is there a way to make the wck version to work or there is a bug in it?

Thank you.
I'm not sure exactly what's going on but there's a couple things I see wrong:

Quote:
Util.addChildAbove(joint, newBubble);
joint.create();


You don't need to call joint.create(). This is called automatically when you add it to the stage.

Also try setting the x & y of your joint object to the x & y of your target1Object. Try that and see if it fixes things.
Thank you mayobutter, I'll try that.

Gergely
Thanks Mayobutter, it worked fine with your suggestions! 😉
Code:
var j:Joint = new Joint();
j.type = "Distance";
j.bodyShape1 = parent.bubble;
j.bodyShape2 = newBubble;
Util.addChildAtPos(view.MLM_WORLD, j, parent.bubble);

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