Animating IK Armatures Overview

After creating an IK armature, use the fl.ik classes to limit its movement, track its events, and animate it at runtime.

The following figure shows a movie clip named Wheel. The axle is an instance of an IKArmature named Axle. The IKMover class moves the armature in synchronization with the rotation of wheel. The IKBone, ikBone2, in the armature is attached to the wheel at its tail joint.

A.
Wheel

B.
Axle

C.
ikBone2

At runtime, the wheel spins in association with the __motion_Wheel motion tween described in Describing the animation in the Working with motion tweens chapter. An IKMover object initiates and controls the movement of the axle. The following figure shows two snapshots of the axle armature attached to the spinning wheel at different frames in the rotation.

Moving IK armature in two different positions
At runtime, the following ActionScript:
  • Gets information about the armature and its components

  • Instantiates an IKMover object

  • Moves the axle in conjunction with the rotation of the wheel

import fl.ik.* 
 
var tree:IKArmature = IKManager.getArmatureByName("Axle"); 
var bone:IKBone = tree.getBoneByName("ikBone2"); 
var endEffector:IKJoint = bone.tailJoint; 
var pos:Point = endEffector.position; 
 
var ik:IKMover = new IKMover(endEffector, pos); 
ik.limitByDistance = true; 
ik.distanceLimit = 0.1; 
ik.limitByIteration = true; 
ik.iterationLimit = 10; 
 
Wheel.addEventListener(Event.ENTER_FRAME, frameFunc); 
 
function frameFunc(event:Event) 
{ 
    if (Wheel != null) 
    { 
        var mat:Matrix = Wheel.transform.matrix; 
        var pt = new Point(90, 0); 
        pt = mat.transformPoint(pt); 
         
        ik.moveTo(pt); 
    } 
}

The IK classes used to move the axle are:

  • IKArmature: describes the armature, a tree structure consisting of bones and joints; must be created with Flash

  • IKManager: container class for all the IK armatures in the document; must be created with Flash

  • IKBone: a segment of an IK armature

  • IKJoint: a connection between two IK bones

  • IKMover: initiates and controls IK movement of armatures

For complete and detailed descriptions of these classes, see the ik package.