After Effects Expressions 503 – Objects & Properties

Expressions use a series of objects
to reference values through your project. JavaScript is an object-based programming
language that allows expressions to link these objects together. The standard object hierarchy chain in After
Effects looks something like this. When referencing objects and their attributes
in an After Effects expression, you must use a statement like this to specify the composition, layer,
effect, property, and/or attribute you’re linking to. There are five main parts to this statement,
left to right, separated by period operators. The first two elements represent a composition
and the layer inside the comp within the object hierarchy. The third element is an effect object
applied to the layer. The fourth element is the specific effect
property you are referring to. And finally, the fifth element
is the property attribute. After Effects expressions are always applied
to the property level. Expression syntax defaults to the current
composition and the current layer. So, if your expression refers to a neighboring
effect property on the same layer, you can omit the comp and layer objects
in your reference. However, if you target any effect
that’s not on the same layer, then both the composition
and the layer must be specified. A composition object represents
a global comp object, which is the starting point
in the object hierarchy. A composition object can be:
thisComp or comp(“Name”) If there are more than one composition with
the same name, it returns the first instance, top to bottom, from the Project Panel. A layer object represents a specific layer,
the second level in the object hierarchy chain. A layer object can be
layer(1) or layer(“Name”) If there are more than one layer with the
same name, it returns the first instance, top to bottom, in the Timeline. The layer object is chained to the composition
object, placed immediately after and separated by a period operator. An effect object represents a layer’s specific
effect, the third level in the object hierarchy. The effect object can be effect(“Name”)
or it can be a long-form legacy reference with (“Effects”)(“Fast Box Blur”) The effect object is chained to the layer
object, and it’s placed immediately after and separated by a period operator. The property and property attribute are the
fourth and fifth levels in the object hierarchy chain. A property and it’s attribute may appear as:
position.value or (“Property Name”).speed The property is chained to the effect object,
and it’s placed immediately after with no period operator. An attribute follows the property
and is separated by a period operator. Syntax at this level can be kind of tricky
so, when in doubt, just pick whip the property and use the auto syntax. Universal expressions give you the ability
to share a project with somebody working in another language. This is a very useful feature
for template creation. Universal expressions require slight modification
to the object references in your expressions. This is due to the difference in how languages
interpret properties and effects in After Effects. So here’s the standard expression syntax:
effect(“Effect Name”)(“Property Name”) To quickly and easily make most expressions
universal, you must do two things: 1) Replace the effect property’s name
with the property’s index. And 2) Give the effect object a custom name to avoid any localization errors with the default effect names. When using the Pick Whip tool to link an expression,
you can hold the Alt key on Windows, or Option key on a Mac, and pick whip a property
to swap the property name with the property index. In this case it’s 1, since it’s the first
property from the top of the effect. This quick and dirty method
will work in many cases, but it might cause issues with certain complex effects
and might break when using a deep nested component like shape layer groups and properties. A truly universal expression will use Adobe’s
internal matchnames, which are not localized and work in every version of After Effects,
regardless of the language. This is the gold standard for templates
spanning across multiple languages. In this example, the effect object’s matchname
replaces the default effect name and the default effect property is replaced with a matchname
that references the effect and the property’s index. A great free tool for obtaining an effect’s
matchname is the Gimme Prop Path script from Jeff Almasol’s Redefinery website. Highlight the property you want the matchname
of, and then hit “Get Property Path” which generates that property’s
matchname and syntax. Another useful paid tool for automatically
universalizing an entire project at once is the Expression Universalizer
from AE Scripts. We’ve arrived at the end of Lesson 503:
A Guide to Expression Object Hierarchy and Properties If you enjoy this expressions course,
consider purchasing the paid content. It includes in-depth documentation,
extra tutorial content, high definition videos, and all the project files used in the training. Your purchase will help to create
more free courses like this in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *