Ultrashock Tutorials > After Effects > Parent-Child Animations  
 
by: John Nack, Adobe


Source File

 
Parent-Child Animations
 

 

After Effects 5 features powerful tools for animating parent-child animations. When you assign a parent to a layer, the child layer's properties become relative to the parent layer instead of to the composition. Parenting is useful for creating complex animations such as linking the movements of a marionette or depicting the orbits of planets in the solar system.

In this example I'll establish parenting relationships between the layers of an Illustrator file (courtesy of Ian Byers), then animate the layers and export a SWF to tweak in Flash.

I set up the After Effects project file (parenting.aep) with comps that show an Illustrator file at various stages of development (clearly you can create something more interesting if you'd like). You can grab the source files, including the optimized FLA, here (parenting.zip, Mac/Win). If you're already familiar with parenting in After Effects, you can jump to the final section on importing and optimizing in Flash.

Creating and importing the artwork

Create some shapes in Illustrator 9 to use as the basis of the limbs of a character, then distribute each limb to a layer and name each layer. Save the file (I called mine robot.ai).

In After Effects, create a new project with a comp choose

File->Import

then select Import as: Composition. After Effects will import all the layers of the Illustrator file and build a composition that preserves their positions. Be aware that when exporting SWF, After Effects will rasterize all nested compositions regardless of their contents, so instead of dragging the new comp to the timeline, drag the folder that contains all the Illustrator layers. The layers will maintain their stacking order, names, and relative positions. (The comp "Imported" shows this task completed.)

Setting anchor points & using solo

Use the Pan Behind tool in After Effects to drag the center points of the various Illustrator layers so that they match the figure's joints.

Since you're dealing with 12 layers that have the same bounding box and initial anchor point, it's easy to click and adjust the wrong layer. Rather than clicking on and off eyeballs or lock icons, you may find it easier to use the solo key to isolate individual layers. (The comp "Centered" shows this task completed.)

Establishing parenting relationships

Once you've set the anchor points correctly, establishing parent-child links is as simple as point and shoot. You can either drag the parenting pick whip from ( see screenshot below) a child to a parent, or select a parent from the popup list in the parenting area.

Use either method to establish the hierarchies you'd expect in a human body (right foot connected to right shin, right shin connected to right thigh, right thigh connected to pelvis, etc.). I find it easiest to begin with the outermost point and work my way inward until the torso is the parent of everything. (The comp "Parented" shows this task completed.)

Animating the layers

Now you're ready to see parenting in action. Select the left upper leg on the timeline and hit "R" to display the rotation values of the layer. By dragging the rotation value back and forth, you should see the upper leg swing, and the lower leg and foot should swing with it. Now select the right lower leg and adjust its rotation values in the same way. You should see the lower leg and foot rotate together, but the upper leg will remain unaffected. This is the essence of parenting in After Effects: parents' movements propagate down to children, but not vice-versa.

Now set the stopwatches for the values you want to animate, then adjust the values at various times. I animated rotation only, but all values except opacity respond to parenting. If there are layers which you know you're not going to animate, or which you want to hide temporarily in the timeline, you can set the shy switch (by clicking each layer's little face icon) on the layers you want to hide, then clicking the Hide Shy Layers button above them.

I isolated the moving elements by selecting all and hitting "U". After Effects now shows me only attributes for which animation stopwatches have been set. If a layer doesn't have any animated attributes, I set it to shy and enable the Hide Shy Layers button. (The comp "Animated" shows this the artwork animated and ready for export.)

€ Exporting and optimizing in Flash The final step is to export the After Effects SWF and import it into Flash. You could simply choose

File->Export->Macromedia Flash

, but it's usually more efficient to isolate chunks of movement and export them separately. That way it¹ll be easier to eliminate unnecessary keyframes after importing the SWF. In my file, the arms/head/torso section can be separated from the leg (see screenshot below), and the left leg can be separated from the right leg.

So, I set solo keys for just the layers I want to export in each group. I export torso.swf, leg_l.swf, and leg_r.swf using the default export settings.

In the Flash import dialog box, choose all three SWFs and import them. Flash will stack the SWFs as series of keyframes. Label each layer appropriately. You don't need more than one keyframe for the non-moving content, so on the right leg layer select all keyframes after #1 and hit Clear Keyframe (Shift-F6). Then look for areas in which the other portions aren¹t animating and eliminate duplicate keyframes.

Notice in the library that After Effects has created a large number of symbols. Because it allows you to use a fixed or morphing mask on each layer, After Effects creates a new mask shape for each vector object on every frame and wraps the mask and layer together in a movie clip. If you aren't using After Effects masking, these symbols are extraneous and can be safely removed to reduce file size.

To remove the extra masks, select each frame in the moving layer and hit
Cmd-B to break apart. You'll see something like this:

Fortunately it's easy to select the red rectangles (which had functioned as masks) and delete them. I generally step through each frame, select all, and break apart, then go back through to select and delete the masks. Be sure not to break apart each frame more than once, or you'll reduce the symbols to paths and increase the size of your SWF. It may take a couple minutes of work, but you can cut considerable size off the After Effects SWF (in this case, I cut the SWF from 60kb to 18kb).


 

 
©2001 Ultrashock.com Inc. - All rights reserved