# Box2D ActionScript Pulley Joint Tutorial: Add Bodies

Joints in Box2D Physics simulation are used to constrain bodies to the world or to each other. We discuss how to create Pulley Joints in very details in this series of flash physics simulation.

Please update flash player to view this Flash ActionScript tutorial!

## Flash Box2D Physics Simulation Tutorial Content

A Pulley Joint is used to create an idealized pulley. The pulley connects two bodies to ground and to each other. As one body goes up, the other goes down. The total length of the pulley rope is conserved according to the initial configuration.

In this example:
Length of pulley rope (Blue box) = L1 = 300
Length of pulley rope (Danger box) = L2 = 300

L1 + L2 = constant

STEP 1: Add Bodies to Stage and Keep Static
Since the initialization function of Box2D assumes that the bodies are already in the correct position , the first step is to add bodies on the stage to make sure that they are in correct position. This is best to keep all bodies in static for easy position analysis.

Distance (Up or Down) allow to Move Up and Down:
We mainly concern a ratio 1:1 in this example. A ratio 1:1 means that both two bodies in the Pully Joint are allow to move the same amuint. And the Box2D Physic Scale is 100, i.e. 1 meter in Box2D Physics world = 100 pixel.

 Length of Pulley Rope (pixel) 250 300 350 400 Moving Distance Up or Down (pixel) 50 100 150 200

You can easily seen that whenever the Length of Pulley Rope increase by 50 pixel, the moving distance of the two bodies are increased by 50 pixel also.

In our example, we will use 250 pixels for the Length of Pulley Rope. Therefore one box will be moving up by 50 pixel, while the other box will be moving down by 50 pixel. However the total length of the Pulley Rope is always remains constant.