Another cool new feature in Flash CS4 Professional is the ability to create an armature using the Bone tool. An armature is a series of symbols or shapes that are linked so that they move in relation to each other when clicked on or animated. This method of animation is called inverse kinematics (IK). The classic example is a puppet on marionette strings. The puppet is made up of limbs bound together at the joints. When the puppeteer moves any of the strings, the limbs connected to that joint move in relation to the limb that changed position.
Armatures add new visual states to the Flash authoring environment (see Figure 6). The lines that connect the center points of the objects are called bones. The joints at which the bones connect can be selected so that unique properties and constraints can be applied to each section of the armature.

Figure 6. Shape with an armature added (left) and several symbols with bones attached (right)
The first thing to mention is that armatures cannot be dynamically created at runtime. They must be created at authortime using the Bone tool in Flash CS4 Professional. This is easy.
Once you've created an armature, you can save it in a movie clip and animate it using ActionScript at runtime. So in terms of programmatic animation, working with armatures is a two-step process where the first step involves building the armature in a FLA file in Flash.
Follow these steps to create an armature:
Duplicate the instance four times and place the duplicates above, below, and to the sides of the first circle. Add two more duplicates below the circles on either side (see Figure 7).

Figure 7. Bone markers connecting the segments in the armature
To set up the armature for runtime manipulation, click on the first keyframe in the armature layer to select it. In the Property inspector, change the Type options field from Authortime to Runtime (see Figure 8).

Figure 8. Armature settings for runtime use
In this sample the animation actually happens as part of the behavior of the armature. When you publish the movie, you can click on the circles to see them move in relation to one another. To visualize the segments of the armature better, and to provide a foundation for some interesting animation possibilities, the following code addition will analyze the armature using ActionScript and draw lines between the joints.
Follow these steps to finish off the sample:
Select the first frame of the Actions layer and open the Actions panel. Copy and paste the following code into the panel:
import fl.ik.*;
import flash.display.Sprite;
// Retrieve the armature and the root joint
var armInst:IKArmature = IKManager.getArmatureAt(0);
var rootJnt:IKJoint = armInst.rootJoint;
var lineContainer:Sprite = new Sprite();
// Add a container for drawing lines
// to the bottom of the display object stack
addChild(lineContainer);
setChildIndex(lineContainer, 0);
// Traverse the armature and draw lines to
// connect the joint...
function drawConnectingLines(jnt:IKJoint):void
{
var len:uint = jnt.numChildren;
for(var n:uint=0;
n<len; n++)
{
var childJnt:IKJoint = jnt.getChildAt(n);
var childClip1:DisplayObject = getChildByName(childJnt.bone.headJoint.name);
var childClip2:DisplayObject = getChildByName(childJnt.bone.tailJoint.name);
lineContainer.graphics.lineStyle(3, 0xCCCCCC);
lineContainer.graphics.moveTo(childClip1.x, childClip1.y);
lineContainer.graphics.lineTo(childClip2.x, childClip2.y);
drawConnectingLines(childJnt);
}
}
// Update line drawing every frame
function enterFrameHandler(event:Event):void
{
lineContainer.graphics.clear();
drawConnectingLines(rootJnt);
}
addEventListener(Event.ENTER_FRAME,
enterFrameHandler);
For more information about this feature, see About inverse kinematics in the Flash documentation.