In the Referencing Layers and Compositions article you learnt how to create references to After Effects compositions and layers in your expressions, as well as their attributes such as their
These objects also have other properties you can access in expressions, which you're unable able to pick whip to as they don't appear in the timeline.
Native attributes are the properties on After Effect's built in objects, such as compositions and layers.
In this article you'll learn how to find and use these native attributes built into After Effects.
Finding and using attributes
The expression language menu
The easiest way to find what attributes are available is via the expression language menu, which is the small arrow next to the pick whip on an property with an expression.
Clicking on the arrow reveals the objects available, with their attributes listed as the items in each sub menu. Selecting one of the attributes will insert it into the expression.
The expression language menu is a way of seeing the native attributes available, and inserting them into your expression.
Below is an example of using the expression language menu to insert a reference to the composition duration (
duration) which you can find under the "Comp" sub menu.
As you can see, inserting the duration property alone results in an error:
Reference Error: duration is not defined
This is because
duration is a property of a composition object, which you can tell as it's found under the "Comp" menu.
As you learnt in the previous article, property references must always begin with their parent object.
Changing the expression to reference the duration of the current composition object (
thisComp) solves the error, and returns the correct duration.
You can know which object to reference by it's location in the expression language menu, whether it's an attribute of a composition, layer or property. For example,
speed is an attribute of Properties as it's found under the "Property" menu.
To learn more about how to reference layers and compositions, see Referencing Layers and Compositions.
The expression language reference
You can also find a list of most of the native attributes available on Adobe's website, as well as explanations on each attribute.
This page is a vital resource for writing expressions, and is worth reading and keeping bookmarked.
Layer and property object references
You may have noticed that for attributes of layer and property objects, such as
thisProperty.numKeys, you can omit the object reference without causing an error.
// With object referencethisLayer.inPoint;// Without object referenceinPoint;
This seems to contradict what you learnt about objects: that you must always reference the parent object before the attribute (
Expression pre processing
The reason layer and property attributes work without the object reference is that After Effects pre-processes expressions to add references to the current layer or property object on native attributes.
// Un processed (invalid) expressioninPoint;numKeys;// Processed (valid) expressionthisLayer.inPoint;thisProperty.numKeys;
For a more in depth look at expressions pre-processing, see the article: What happens during expression pre-processing
This pre processing is not done to code in external
.jsx files, so you must ensure to add the object references yourself in that case.
Whether you add the property references yourself, or let After Effects add them during pre processing, is a matter of preference.
For the sake of being explicit about what objects the attributes belong to, we prefer to add object references in our own expressions.
Commonly used attributes
Below is a list of native attributes most commonly used in expressions, grouped by their parent object. Knowing when and how to use these attributes is a key part of writing expressions.
Attributes on composition objects, such as
comp("Lower Third"), include:
name: The name of the composition
width: The width of the composition in pixels
height: The height of the composition in pixels
duration: The duration of the composition in seconds
numLayers: The number of layers in the composition
Attributes on layer objects, such as
index: The position of the layer in the layer stack
inPoint: The start point of the layer in seconds
outPoint: The out point of the layer in seconds
parent: The layer object of the layers parent
width: The width of the layer in pixels
height: The height of the layer in pixels
Attributes on property objects, such as
numKeys: The number of keyframes on the property
value: The current value of the property
velocity: The current velocity of the property
speed: The current speed of the property
name: The name of the property (e.g. "Opacity")
Native attributes enable you to use properties of layers and compositions in your expression, such as their size and duration. Knowing how to find and use these attributes is a key part of writing expressions.
There are also functions built into these objects, known as native methods, which you will learn more about in a future article.