Joint Problem - Alchemy Exit

Hi.
i've searched a lot and tryied a lot of possiblities but i couldn get it to work.

please look at below code.

(i Use Flash Builder + wck)

my hero collide to a box, box name is "tb";

now it should add a "distance" joint witch connect them together:

Code:
var pJoint1:Joint = new Joint();
      pJoint1.type = "None"; // i also tried Revolute Joint
      pJoint1.x = x;
      pJoint1.y = y;
      pJoint1.bodyShape1 =  tb as BodyShape; // i also tried target1Object
      pJoint1.bodyShape2 =  hro as BodyShape;
      addChild(pJoint1);

      var pJoint2:Joint = new Joint();
      pJoint2.type = "Distance";
      pJoint2.bodyShape1 =  tb as BodyShape;
      pJoint2.bodyShape2 =  hro as BodyShape;
      addChild(pJoint1);
      addChild(pJoint2);


but i get object AlchemyExit error:

Code:
[object AlchemyExit]
   at Function/<anonymous>()
   at Function/<anonymous>()
   at Box2DAS.Dynamics.Joints::b2Joint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\Joints\b2Joint.as:21]
   at Box2DAS.Dynamics.Joints::b2DistanceJoint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\Joints\b2DistanceJoint.as:20]
   at wck::Joint/createDistanceJoint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\Joint.as:653]
   at wck::Joint/createJoint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\Joint.as:536]
   at wck::Joint/create()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\Joint.as:391]
   at misc::Entity/ensureCreated()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\misc\Entity.as:50]
   at misc::Entity/handleAddedToStage()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\misc\Entity.as:100]
   at flash.display::DisplayObjectContainer/addChild()
   at MyWorld/pushObj()[D:\Adobe Flash Builder\Rebox\src\MyWorld.as:652]
   at Hero/handleContact()[D:\Adobe Flash Builder\Rebox\src\Hero.as:81]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at Box2DAS.Common::b2EventDispatcher/dispatchEvent()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Common\b2EventDispatcher.as:27]
   at Box2DAS.Dynamics::b2ContactListener/ContactDispatch()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2ContactListener.as:64]
   at Box2DAS.Dynamics::b2ContactListener/BeginContact()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2ContactListener.as:31]
   at Box2DAS.Dynamics::b2World/BeginContact()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2World.as:346]
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at global/AS3_CallTS()
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at Function/<anonymous>()
   at cmodule.Box2D::FSM__ZN13WorldListener12BeginContactEP9b2Contact/work()
   at Function/<anonymous>()
   at Function/<anonymous>()
   at Box2DAS.Dynamics::b2World/HandleStep()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2World.as:162]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at Box2DAS.Common::b2EventDispatcher/dispatchEvent()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Common\b2EventDispatcher.as:27]
   at Box2DAS.Dynamics::b2World/Step()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2World.as:158]
   at wck::World/step()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\World.as:198]



tanks for replyes.... i should get this to work as soon as possible...
I use Flash IDE but my code is pretty much the same.

j1 = new Joint();
j1.type = "Revolute";
j1.bodyShape1 = carBody;
j1.bodyShape2 = wheel1;
j1.x = wheel1.x;
j1.y = wheel1.y;
Util.addChildAtPos(MyWorld, j1, wheel1);

If you are using all of the code that you mentioned. Why are you adding two joints? One should be enough.

pJoint1.type = "None";
That is probably not a good idea.

Other than that, I'm not sure.
Are you trying to create the joint mid-timestep? That's the most common error. You have to wait until the timestep ends to create joints / bodies.
Taaaanks A Lot!
It works like a charm now!

it solved by adding
Code:
_world.doOutsideTimeStep(addJointsFunc);



tanQ veryyyyyyy Much ! 🙂

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