Learn about expressions and expression references such as time conversion methods and vector math methods in After Effects. Expression to a text layer's Source-Text property (it doesn't matter what the text AE already gives you the seconds since the beginning of the Comp (the loca-. After Effects Advanced + Expressions - 3 days the Adobe Certified Expert (ACE ) status in After Effects. . (electronic book/PDF or movies) to download or a.
|Language:||English, Spanish, Portuguese|
|ePub File Size:||18.49 MB|
|PDF File Size:||14.66 MB|
|Distribution:||Free* [*Sign up for free]|
Its icon looks like a little spiral. Create a Comp with a single layer in it a small solid or use the layer in Chaper Add an Expression to Rotation. Just leave the default Expression there. Point to the Pick Whip, and hold down the left mouse button. Notice that AE wrote the Expression for you: transform. Notice also that I printed that last Expression in red.
Read pages 11 through 19 - pages xi through xix of the Introduction from the Marcus Geduld After Effects Expressions textbook. AE Expressions: Chapter 1 - Creating Simple Expressions - we will read and study this entire chapter before spring break gets here.
Pages of the PDF cover the Write-on and the Beam effect that we did to start off the 5th week of class, the day after soup or sundae. Here is the snow falling and chimney smoke rising application we did on Wednesday, February 10th, We used the WIGGLE expression to make the smoke particle playground effect simulate being effected by wind or perhaps by gentle breezes.
Watch the smoke coming out of the chimney. The smoke wiggled around due to the wiggle 0. Create a Comp with two small solids in it, a red one and a green one.
Or you can use the two layers in Chapter Select Green and press the P key to reveal its Position property. Select Red and press the S key to reveal its Scale property. And the Expression is telling it. The drilling down can get even more complicated, because, via the Pick Whip, you can hook up a property in one Comp with a property in another Comp.
Open Chapter Select the Solid, and type S to reveal its Scale property. Now open Chapter Select the Solid and type P to reveal its Position property. The Expression looks like this: comp "Comp 6". Something in a Comp. Which Comp? Comp 6. What thing in Comp 6?
A layer. Which layer? What item in that group? The Position property. It does what it does. Every time I added an Effect or several Effects , I paused and thought about whether it would be fun to link two Effect properties so that one controlled the other.
But it just took a couple of seconds to add an Expression and use the Pick Whip. In a new second Comp, create a Comp-sized solid or use the one in Chapter Keep doing this until the CTI has reached the end of the Timeline. The beam is shorter than it could be. This will allow you to adjust the beam by dragging in the Comp window.
You can do it there or in the Timeline. Preview the Comp. As you can see, the brush is controlling the beam though it looks the other way around. You could try the same effect with Write-on and an image of a pencil, crayon, or marker. This makes it a great effect for use with Expressions. Or you can rig things the other way around. The possibilities are endless. Create a new 5-second Comp. Or you can use Chapter If necessary, use the alignment options in the Paragraph panel to center the text.
In the Timeline, twirl open the Type layer and then open the Animation menu in the Timeline. Select the Tracking option to add a Tracking Animator to the Timeline.
Track as much as you like. If you preview again, the movement should be a little smoother.
In the Effect Controls panel, add an Expression to the Blurriness property. As the letters spread apart, they become blurrier. As they come back together, they return to focus. But in the future, as you add Effects, play matchmaker. Use the Pick Whip to bring properties closer together. Vive la difference! And I also promise to hold your hand through the whole process and to go slowly.
Why bother with all this stuff? Because you need to understand it in order to move beyond simple, Pick Whip-based Expressions. But we do need to revisit them. As you may remember—or as you may not—variables are letters that stand in for numbers, as in this problem: 41 PART 1 Using Expressions Variables are called variables because they can change what they stand for they vary. In that problem, X means 4. But in this problem, it means By the way, the opposite of a variable is a constant.
The digit 3 is a constant as are all the other digits. It always means 3. It never means anything else. The name value is the name of the marker, as typed in the comment field in the marker dialog box, for example, marker. For a composition marker, the default name is a number. If more than one marker in the composition has the same name, this method returns the marker that occurs first in time in composition time.
The value for a marker key is a String, not a Number. For example, this expression returns the time of the composition marker with the name "0":. Returns the marker that is nearest in time to t. For example, this expression returns the time of the composition marker nearest to the time of 1 second:. Returns the Camera object for the camera through which the composition is rendered at the current frame. This camera is not necessarily the camera through which you are looking in the Composition panel.
Apply the following expression to the Position property of a layer to center the layer in the composition frame:.
You can also access a footage object using the source attribute on a layer whose source is a footage item. Returns the source Comp or source Footage object for the layer. Default time is adjusted to the time in the source.
If multiple effects have the same name, the effect closest to the top of the Effect Controls panel is used. After Effects finds the effect by its index in the Effect Controls panel, starting at 1 and counting from the top. If multiple masks have the same name, the first topmost mask is used.
After Effects finds the mask by its index in the Timeline panel, starting at 1 and counting from the top. Returns the width of the layer, in pixels. It is the same as source. Returns the height of the layer, in pixels. Returns the parent Layer object of the layer, if it has one.
Use the hasParent attribute to determine if a layer has a parent layer.
You can use this attribute even if the layer has no parent layer at present. For example, the following expression indicates that the layer to which you apply it wiggles based on the position of the parent. If the layer has no parent, then it wiggles based on its own position. If the layer is given a parent later, then the behavior of the layer changes accordingly:.
In general, the value of outPoint is greater than the value of inPoint. However, if a layer is reversed in time, the value of inPoint is greater than the value of outPoint. Similarly, the value of startTime can be greater than the value of inPoint. Returns true if the Video switch is on for the layer and the current time is in the range from the In point of the layer to the Out point of the layer; false otherwise.
Returns true if the Video switch is on for the layer; false otherwise. Returns true if the Audio switch is on for the layer and the current time is in the range from the In point of the layer to the Out point of the layer; false otherwise.
Samples the color and alpha channel values of a layer and returns the average alpha-weighted value of the pixels within the specified distance of the point as an array: If postEffect is true, the sampled values are for the layer after masks and effects on that layer have been rendered; if postEffect is false, the sampled values are for the layer before masks and effects have been rendered.
The input value point is in layer space; the point [0,0] is the center of the upper-left pixel in the layer. The input value radius specifies the horizontal and vertical distance from the sample center to the edges of the sampled rectangle. The default value samples one pixel. The postEffect parameter refers to effects applied directly to the layer, not to effects applied indirectly, such as with an adjustment layer.
Using sampleImage in an expression no longer disables multiprocessing. This example samples a rectangle 4 pixels wide and 3 pixels high, centered around a point pixels down and to the right of the upper-left corner of the layer:. Dan Ebberts provides an example of how to use the sampleImage method on his MotionScript website. Todd Kopriva provides instructions for using the sampleImage method and the Point Control effect to monitor colors for a specified point during color correction on his After Effects Region of Interest blog.
When you add masks, effects, paint, or text to a layer, After Effects adds new properties to the Timeline panel. There are too many of these properties to list here, so use the pick whip to learn the syntax for referring to them in your expressions. Returns the position value of the layer, in world space if the layer has no parent. If the layer has a parent, it returns the position value of the layer in the coordinate system of the parent layer in the layer space of the parent layer.
Returns the rotation value of the layer in degrees. For a 3D layer, it returns the z rotation value in degrees. Returns the value of the Audio Levels property of the layer, in decibels.
This value is a 2D value; the first value represents the left audio channel, and the second value represents the right. The value is not the amplitude of the audio track of the source material.
Instead, it is the value of the Audio Levels property, which may be affected by keyframes. Returns the MarkerKey object of the layer marker with the specified name. If more than one marker on the layer has the same name, this method returns the marker that occurs first in time in layer time.
This expression on a property ramps the value of the property from 0 to between two markers identified by name:. Returns the layer marker that is nearest in time to t. For example, this expression returns the time of the marker on the layer nearest to the time of 1 second:. Use layer space transform methods to transform values from one space to another, such as from layer space to world space. Each transform method takes an optional argument to determine the time at which the transform is computed; however, you can almost always use the current default time.
Composition comp and world space are the same for 2D layers. For 3D layers, however, composition space is relative to the active camera, and world space is independent of the camera. Transforms a point from composition space to layer space.
The resulting point in a 3D layer may have a nonzero value even though it is in layer space. Dan Ebberts provides an expression on his MotionScript website that uses the toWorld method to auto-orient a layer along only one axis. This is useful, for example, for having characters turn from side to side to follow the camera while remaining upright. Rich Young provides a set of expressions on his AE Portal website that use the toWorld method link a camera and light to a layer with the CC Sphere effect.
Transforms a point from world space to layer space. See Expression example: Create a bulge between two layers for an example of how this method can be used. Transforms a vector from layer space to composition space. Transforms a vector from layer space to world space. Transforms a vector from world space to layer space. Projects a point located in composition space to a point on the surface of the layer zero z-value at the location where it appears when viewed from the active camera.
This method is useful for setting effect control points. Use with 3D layers only. Camera objects have the same attributes and methods as Layer objects, except for source , effect , mask , width , height , anchorPoint , scale , opacity , audioLevels , timeRemap , and all the material properties. Returns true if the camera is the active camera for the composition at the current time: Returns false otherwise. Light objects have the same attributes and methods as Layer objects, except for source , effect , mask , width , height , anchorPoint , scale , opacity , audioLevels , timeRemap , and all the material properties.
David Van Brink provides an instructional article and sample project on his omino pixel blog that show how to use expressions with lights. Returns true if the effect is turned on the Effect switch is selected. Returns a property within an effect. Effect control points are always in layer space. For example, effect "Bulge". You can link Mask Path properties to other path properties paths in a shape layer and brush strokes , but the properties are not accessible for direct numerical manipulation through expressions.
For example, to have a property value for each frame chosen randomly from a set of four values, set your four values as keyframes at 0, 1, 2, and 3 seconds, and then apply the following expression to the property:. Returns the temporal velocity value at the current time. For spatial properties, such as Position, it returns the tangent vector value. The result is the same dimension as the property. Returns a 1D, positive speed value equal to the speed at which the property is changing at the default time.
This element can be used only for spatial properties. This value controls how much detail is in the wiggle. Make this value higher than the default of 1 to include higher frequencies or lower to include amplitude harmonics in the wiggle. This value controls how fast the harmonics drop off.
The default is 0. This value defaults to the current time. Use this parameter if you want the output to be a wiggle of the property value sampled at a different time. In addition to the main wiggle, two more levels of detailed wiggles occur with a frequency of 10 and 20 wiggles per second, and sizes of 10 and 5 pixels, respectively. This example, on a two-dimensional property such as Scale, wiggles both dimensions by the same amount:. Dan Ebberts provides an example expression and a detailed explanation on his MotionScript website that shows how to use the time parameter of the wiggle method to create a looping animation.
Samples the property at a wiggled time. For this function to be meaningful, the property it samples must be animated, because the function alters only the time of sampling, not the value. Smooths the property values over time, converting large, brief deviations in the value to smaller, more evenly distributed deviations. This smoothing is accomplished by applying a box filter to the value of the property at the specified time.
The width value is the range of time in seconds over which the filter is averaged.
The samples value is the number of discrete samples evenly spaced over time; use a larger value for greater smoothness but decreased performance. Loops a segment of time that is measured from the first keyframe on the layer forward toward the Out point of the layer.
The loop plays from the In point of the layer. The numKeyframes value determines what segment is looped: For example, loopIn "cycle", 3 loops the segment bounded by the first and fourth keyframes. The default value of 0 means that all keyframes loop. You can use keyframe-looping methods to repeat a series of keyframes. You can use these methods on most properties. Keyframes or duration values that are too large are clipped to the maximum allowable value. Values that are too small result in a constant loop.
Repeats the specified segment, but offsets each cycle by the difference in the value of the property at the start and end of the segment, multiplied by the number of times the segment has looped. Does not repeat the specified segment, but continues to animate a property based on the velocity at the first or last keyframe. This type does not accept a keyframes or duration argument. Loops a segment of time that is measured from the last keyframe on the layer back toward the In point of the layer.
The loop plays until the Out point of the layer. The specified number of keyframes determines the segment to loop. The numKeyframes value sets the number of keyframe segments to loop; the specified range is measured backward from the last keyframe. For example, loopOut "cycle", 1 loops the segment bounded by the last keyframe and second-to-last keyframe.
See the entry for loopIn for more information. David Van Brink provides an instructional article and sample project on his omino pixel blog that show how to use the Echo effect, the Particle Playground effect, and the loopOut method to animate a swarm of stylized swimming bacteria.
Specified duration determines the segment to loop. The duration value sets the number of composition seconds in a segment to loop; the specified range is measured from the first keyframe. For example, loopInDuration "cycle",1 loops the first second of the entire animation. The default of 0 means that the segment to loop begins at the layer Out point. Specified duration determines the segmetn to loop. The duration value sets the number of composition seconds in a segment to loop; the specified range is measured backward from the last keyframe.
For example, loopOutDuration "cycle", 1 loops the last second of the entire animation. The default of 0 means that the segment to loop begins at the layer In point. Returns the Key or MarkerKey object by number.
For example, key 1 returns the first keyframe. Returns the number of keyframes on a property. Returns the number of markers on a marker property. If you use the Separate Dimensions command to separate the dimensions of the Position property into individual components, the number of keyframes changes, so the value returned by this method changes.
Returns a group of properties relative to the property on which the expression is written. For example, if you add the propertyGroup 1 expression to the Rotation property of a brush stroke, the expression targets the Transform property group, which contains the Rotation property. If you add propertyGroup 2 instead, the expression targets the Brush property group. This method lets you establish name-independent relationships in the property hierarchy.
This method is especially useful when duplicating properties that contain expressions. The numProperties method for propertyGroup returns the number of properties in the property group. This example returns the number of properties in the group that contains the property on which the expression is written:. Returns the index of a property relative to other properties in its property group, including property groups within masks, effects, text animators, selectors, shapes, trackers, and track points.
In this example, the propertyGroup method for each brush stroke targets the Brush property group because that group is two property groups up from the Rotation property.
The propertyIndex attribute in each Brush stroke then returns a unique value for each Brush stroke. The resulting value is then multiplied by the time and and applied to each rotation value, rotating each brush stroke differently, creating swirling paint strokes: When you access a Key object, you can get time , index , and value properties from it.
For example, the following expression gives you the value of the third Position keyframe: The following expression, when written on an Opacity property with keyframes, ignores the keyframe values and uses only the placement of the keyframes in time to determine where a flash should occur: You can access values for composition markers and layer markers using the same methods. Access layer markers through the thisLayer. For the purpose of expressions, markers are a special type of Key object, so you can use methods such as nearestKey time to access markers, and markers also have time and index attributes.
The index attribute is not the number name of the marker; it is the keyframe index number, representing the order of the marker in the time ruler.
Expressions have access to all the values for a marker that you can set in the Composition Marker or Layer Marker dialog box. This expression on the Source Text property of a text layer displays the time, duration, index, comment name , chapter, URL, frame target, and cue point name for the layer marker nearest the current time, and whether the marker is for an event cue point:.
Because the XMP metadata in a footage item can be converted into layer markers for a layer based on that item, expressions can interact with XMP metadata. Apply this to the source text property of a text layer for a readout of the coordinates and incoming and outgoing tangents of the shape.
The example reads the coordinates of the first vertex of Mask 1 on Dark Gray Solid 1 and converts them to composition coordinates. Apply this to a 2D point control of an effect, such as Write-on or CC Particle Systems II, to make the effect trace or track the first point of an animated mask. Duplicate the effect and change the path points index value  to trace or track the other points of the mask. Typical use is to assign a. JSON file's sourceData to a variable, and then reference the desired data stream.