Inverse kinematics (IK) is a great technique for creating realistic motion. Inverse kinematics refers to the use of the kinematics equations of a robot to determine the joint parameters that provide a desired position of the robotic arm.
You can change arm piece number easily. To do that, you must update the lengthArray and partArray. Also, you must add that piece to the stage.
//lengths of each part
var lengthArray:Array=new Array(60,80,100,20);
//update array for each part
var partArray:Array=new Array(part_1,part_2,part_3,part_4);