IT tutorials
 
Graphics
 

Adobe After Effects CS5 : Expressions - Using a Layer’s Index

5/30/2013 9:09:06 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

A layer’s index attribute can be used as a simple but powerful tool that allows you to create expressions that behave differently depending on where the layer is situated in the layer stack. The index attribute corresponds exactly to the number assigned to the layer in the Timeline window. So, the index for the layer at the top of the stack is 1, and so on.

Time Delay Based on Layer Index

Suppose you keyframed an animation for one layer. Now you want to create a bunch of identical layers, but you want their animations to be delayed by an amount that increases as you move down the layer stack. You also want to rotate each copy by an amount proportional to its position in the layer stack. To do so, you first apply an expression like this to the top layer’s animated properties:

delay = 0.15;
valueAtTime(time - (index-1)*delay)

Then you apply an expression like this to the Rotation property:

offsetAngle = 3;
value +(index-1)*offsetAngle

Finally, duplicate the layer a bunch of times. The animation of each layer will lag behind the layer above it by 0.15 seconds and the rotation of each layer will be 3 degrees more than the layer above (Figure 1).

Figure 1. Notice how the blaster shot created by each layer lags that of the previous layer and is at a slightly different angle.


What’s going on here? In the first expression, the first line defines a JavaScript variable named delay and sets its value to 0.15 seconds. The second line is where all the action is, and it’s packed with new things. For example, notice the use of time. It represents the current composition time, in seconds. In other words, time represents the time at which the expression is currently being evaluated.

You use valueAtTime() to access a property’s pre-expression value at some time other than the current comp time (to access the pre-expression value at the current comp time, use value() instead, as in the Rotation expression). The parameter passed to valueAtTime() determines that time:

time – (index-1)*delay

Subtracting 1 from the layer’s index and multiplying that result by the value of the delay variable (0.15) gives the total delay (in seconds) for this layer. Subtracting 1 from index means that the delay will be 0 for the first layer. So, for Layer 1, the total delay is 0, for Layer 2 it is 0.15, for Layer 3 it is 0.30, and so on. You then subtract the total delay from the current comp time. The result of this is that Layer 1’s animation runs as normal (not delayed). Layer 2’s animation lags behind Layer 1 by 0.15 seconds, and so on.

Tip

Remember, if you don’t specify a comp and layer when referencing a property or attribute, After Effects assumes you mean the layer with the expression. When you reference an attribute of the property housing the expression, After Effects makes a similar assumption, allowing you to specify only the attribute name (without the entire comp/layer/property path). One side benefit of not having to specify the entire path is that you can apply the same expression to any property, without having to modify it at all.


The Rotation expression is very similar except that it doesn’t reference time. The reason for this is that the first expression is used to offset a keyframed animation in time, while the second expression simply creates a static (not animated) offset for the Rotation property. The first line of the expression defines a variable named offsetAngle. This variable defines the rotation amount (in degrees) by which each layer will be offset from the layer above it. The second line tells After Effects to calculate the layer’s offset and add it to the pre-expression value of the property.

You’ll see other ways to use index in later examples.

 
Others
 
- Adobe After Effects CS5 : Expressions - Linking an Effect Parameter to a Property
- Adobe Fireworks CS5 : Working with Vector Graphics - Customizing fills and strokes (part 4) - Adding to the skyline, Adding windows to the building
- Adobe Fireworks CS5 : Working with Vector Graphics - Customizing fills and strokes (part 3) - Using the Compound Shape tool, Working with compound shapes
- Adobe Fireworks CS5 : Working with Vector Graphics - Customizing fills and strokes (part 2) - Customizing the stroke, Importing and resizing a vector object
- Adobe Fireworks CS5 : Working with Vector Graphics - Customizing fills and strokes (part 1) - Adding a gradient fill
- Adobe Flash Professional CS5 : Working Within the Flash Environment - Setting General Preferences
- Adobe Flash Professional CS5 : Working Within the Flash Environment - Creating Keyboard Shortcuts
- Adobe Flash Professional CS5 : Working Within the Flash Environment - Creating a Workspace
- Adobe InDesign CS5 : Working with Objects and Layers - Repeating Object Transformations
- Adobe InDesign CS5 : Working with Objects and Layers - Arranging Object Stack Order, Transforming Objects
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us