By Fumio Nonaka
 
Created
26 July 2010
 

Requirements

 
Prerequisite knowledge

Some prior experience working with ActionScript 3 is recommended. Familiarity with the Flash authoring environment is also helpful.
 

 
User level

Beginning
 
This article is the second of seven in a series highlighting examples of programming strategies that make it easier than ever before to create rich content in Adobe Flash CS5 Professional. Adobe Flash Player 10 introduced the ability to control parts of an animation using inverse kinematics (IK). Now, using Flash CS5, you can apply the effect of a spring to an IK armature.
 
The Developer Center article titled Exploring the Spring tool in Flash Professional CS5 explains how to add and control the spring's motion. In order to control an IK armature with ActionScript 3, you must first create the animation elements in the Flash authoring environment.
 
The following sample movie is designed as a bare bones test, so that is easier to understand how to set and control the properties. In a real world example, you can use any number of elements in the armatures you create.
 
  1. Create two objects on the Stage.
  2. Press F8 to convert each object to a movie clip symbol. (In this example, a bitmap graphic of a penguin and a yellow rounded rectangle shape were used to create the two movie clip symbols—but you can use two ovals or other shapes as desired).
  3. Use the Bone tool to draw one IK bone that connects the two symbol instances. While it is selected, enter its name in the Property inspector: ikBoneBar.
  4. In the Property inspector, enable Joint Rotation and set the Constrain values to a minimum value of −45° and a maximum value of 45°.
  5. Rename the layer name of the IK armature to myArmature in the Timeline, as shown in Figure 1.
Notice that when you are working in the authoring environment, you could set the value for Spring by entering a numeric value in the Spring section at the bottom of the Property inspector; leave this value set to 0.
 
Create one IK bone without a Spring setting to build the IK armature.
Figure 1. Create one IK bone without a Spring setting to build the IK armature.
  1. To set the Spring value with ActionScript, select the IK armature in the Timeline and set the Animation Type to Runtime using the Type menu in the Options section of the Property inspector (see Figure 2).
Set the IK armature from Authortime to Runtime in the Type menu.
Figure 2. Set the IK armature from Authortime to Runtime in the Type menu.