Expression Examples - Adobe AFTER EFFECTS CS3 PROFESSIONAL User Manual

Hide thumbs Also See for AFTER EFFECTS CS3 PROFESSIONAL:
Table of Contents

Advertisement

For example, if you have a parameter named "background color", then you can use the following expression to access
its value at the nearest marker:
thisComp.marker.nearestKey(time).parameters["background color"]

Expression examples

Example: Make a layer revolve in a circle
You can create an expression without using properties from other layers. For example, you can make a layer revolve
in a perfect circle.
Select a layer, press P to reveal its Position property in the Timeline panel, and Alt-click (Windows) or Option-
1
click (Mac OS) the stopwatch to the left of the property name.
2
Enter the following in the expression field:
[(thisComp.width/2), (thisComp.height/2)] + [Math.sin(time)*50, -Math.cos(time)*50]
Example: Rotate the hands of a clock
You can use the pick whip to link rotation values between layers to animate the hands on a clock—as the hour hand
moves from hour to hour, the minute hand rotates the full circumference of the clock face. This type of animation
would take a long time to create if you had to set each keyframe for both hand layers, but with the pick whip, you can
do it in a matter of minutes.
1
Import or create two long, narrow solid-color layers: an hour hand and a minute hand. (See "Create or modify a
solid-color layer" on page 140.)
Set the anchor points at the ends of the layers. (See "Work with layer anchor points" on page 157.)
2
3
Move the layers so that the anchor points are at the center of the composition. (See "Move layers in space" on
page 143.)
Set Rotation keyframes for the hour hand. (See "Set keyframes" on page 189.)
4
5
Select the Rotation property for the minute hand and choose Animation > Add Expression.
Drag the pick whip to the hour hand's Rotation property. The following expression appears:
6
thisComp.layer("hour hand").rotation
To make the minute hand rotate 12 times as fast as the hour hand, add
7
thisComp.layer("hour hand").rotation*12
Example: Position one layer between two others
This example expression positions and maintains one layer at a balanced distance between two other layers.
1
Start with three layers. (See "Creating layers" on page 137.)
Animate the positions of the first two layers in the Timeline panel. (See "Creating and modifying motion paths"
2
on page 199.)
3
Select the third layer, press P to reveal the Position property, and Alt-click (Windows) or Option-click (Mac OS)
the stopwatch
button to the left of the property name.
Enter the following in the expression field:
4
at the end of the expression as follows:
*12
AFTER EFFECTS CS3
577
User Guide

Advertisement

Table of Contents
loading

Table of Contents