|
Flash CS4 Resources |
Animating IK Armatures OverviewAfter 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. ![]()
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. ![]() At runtime, the following ActionScript:
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:
For complete and detailed descriptions of these classes, see the ik package. |