IT tutorials
 
Graphics
 

Adobe After Effects CS5 : Expressions - Linking an Effect Parameter to a Property

5/30/2013 9:07:23 PM
- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

1. The Language of Expressions

The After Effects expression language is based on a subset of JavaScript. JavaScript is a scripting language used largely for Web page design and includes many features specifically aimed at that task. The JavaScript implementation for expressions includes the core features only. That means there’s a lot about JavaScript that you won’t need to know, but it also means that any JavaScript reference you pick up (and you’re going to need one if you really want to master expressions) is going to have a lot of content that will be of little or no use to you.

The rest of the expression language consists of extensions that Adobe has added specifically for After Effects. This means that in addition to a good JavaScript reference, you’ll also be frequenting Adobe’s After Effects Expression Element Reference. The most up-to-date version of this reference can be found at Adobe’s Help on the Web. The After Effects Help menu will take you there: Help > After Effects Help, or you can go to www.adobe.com/support/aftereffects.

2. Linking an Effect Parameter to a Property

Here’s the scenario: You want to link an effect to an audio track. Specifically, you want to link the Field of View (FOV) parameter of the Optics Compensation effect to the amplitude of an audio layer. Expressions can’t access audio levels directly, so first you have to use a keyframe assistant (Animation > Keyframe Assistant > Convert Audio to Keyframes) to create a null layer named Audio Amplitude with Slider Controls keyframed for the audio levels of the Left, Right, and Both channels (for a stereo source). Next, you just Alt-click (Opt-click) the stopwatch for the FOV parameter of the Optics Compensation effect and drag the pick whip to the Both Channels Slider property of the Audio Amplitude layer (Figure 1). Doing so generates this expression:

thisComp.layer("Audio Amplitude").effect("Both
Channels")("Slider")

Figure 1. Select the Both Channels slider with the pick whip to replace the highlighted default expression text.

Take a closer look at its syntax: From JavaScript, the After Effects expression language inherits a left-to-right “dot” notation used to separate objects and attributes in a hierarchy. If your expression references a property in a different layer, you first have to identify the composition. You can use thisComp if the other layer happens to be in the same composition (as in this example). Otherwise, you would use comp("other comp name"), with the other composition name in quotes. Next you identify the layer using layer("layer name") and finally, the property, such as effect("effect name")("property name") or possibly transform.rotation.

In addition to objects and properties, the dot notation hierarchy can include references to an object’s attributes and methods. An attribute is just what you would guess: a property of an object, such as a layer’s height or a composition’s duration. In fact, in JavaScript documentation, attributes are actually referred to as properties, but in order to avoid confusion with the layer properties such as Position and Rotation (which existed long before expressions came along), in After Effects documentation (and here) they’re referred to as attributes. For example, each layer has a height attribute that can be referenced this way:

comp("Comp 1").layer("Layer 1").height

Methods are a little harder to grasp. Just think of them as actions or functions associated with an object. You can tell the difference between attributes and methods by the parentheses that follow a method. The parentheses may enclose some comma-separated parameters.

It’s important to note that you don’t have to specify the full path in the dot notation hierarchy if you’re referencing attributes or properties of the layer where the expression resides. If you leave out the comp and layer references, After Effects assumes you mean the layer with the expression. So, for example, if you specify only width, After Effects assumes you mean the width of the layer, not the width of the composition.

Let’s forge ahead. You linked the amplitude of your audio layer to your effect parameter, but suppose you want to increase the effect that the audio level has on the parameter. You can use a little JavaScript math to multiply the value by some amount, like this


thisComp.layer("Audio Amplitude").effect("Both
Channels")("Slider") * 3
 
Others
 
- 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
- Adobe InDesign CS5 : Working with Objects and Layers - Distributing 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
programming4us programming4us
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS