In the article on native attributes you learnt how to find and access the attributes built into the After Effects composition, layer and property objects.
As well as attributes, these object have properties which are functions.
These built in functions are known as native methods.
Finding and using native methods
The same principles learned in the articles on functions and native attributes apply to native methods.
For an in depth look at how to reference the built in objects, and how functions work, see the previous articles in this series.
You can spot the native methods in the expression language menu as they contain parenthesis (
()) after their name, as they are a functions, while native attributes do not have parenthesis.
Some methods also have equals signs in the function parameters, which show the default value of that parameter.
sourceRectAtTime() method pictured above, the default value for the first parameter is
time, and the second parameter defaults to
Commonly used methods
Below is a list of native methods most commonly used in expressions, grouped by their parent object. Knowing when and how to use these methods is a key part of writing expressions.
For a more detailed explanation for each of these methods, see the Expression language reference by Adobe.
Methods on composition objects, such as
comp("Lower Third, include:
layer(index || name): Returns the relevant layer object
marker.key(index || name): Returns the relevant marker object
Methods on layer objects, such as
add(vectorA, vectorB): Adds two vector arrays
mul(vector, amount): Multiplies every dimension of a vector by the amount
clamp(value, limitA, limitB): Constrains a value between the provided limits
random(): Returns a random number between zero and one
Methods on property objects, such as
valueAtTime(time): Returns the value of the property at the input time
smooth(): Applies a box filter to smooth the value of the property over time
nearestKey(time): Returns the key object nearest in time to the input
Native methods are one of main building blocks of expressions, allowing you to perform complex tasks with minimal code.
Knowing how functions and native attributes work gives you further insight into how best to use native methods in your own expressions.