top of page
Search

After Effects Expressions - What are Functions and Methods

  • Writer: Roland Kahlenberg
    Roland Kahlenberg
  • Apr 17
  • 5 min read


An Intelligent Design Asset showing the result of its Responsive & Scalable Feature where design stays consistent, in an automated manner, even as content changes.




Lots of After Effects users who were dipping their feet into Expressions prior to Gen AI are now deep diving into Vibe Coding and finding great value in their exploits.



As Creatives, Gen AI is should be less about content – what it does; and more about knowledge – what you do with it to get what you need/want and what you do after the raw content has been generated.



Knowledge is key to staying relevant today and for the future.

 


It is only by combining coding knowledge into the content creation process can you craft Intelligent Design Assets (IDAs) that intelligently stay on-brand in an automated manner.



This opens up a world of possibilities for both Content Creation and Brand/Campaign Oversight; cutting across Content Creation, Marketing and Branding – so much to gain across different departments of an organization.



One of the biggest Positive Externalities from incorporating IDAs into an organization is the removal of silos as the different departments, in an almost natural manner, come together to solve organizational pain points to achieve single-minded organizational goals.



But before this can happen, it always starts from a little spark.





As long as Creatives shy away or hide from code, their organization will never fully take advantage of Gen AI and will experience poor productivity and creative output and frequent turnovers. It's a rut that will be difficult to get out of unless something drastic happens.



From an After Effects perspective, we're looking at fully leveraging on its built-in Javascript capabilities.



For about 20 years, Expressions, the built-in programming language in After Effects has provided exceptional user-experiences because it solves difficult content creation objectives involving creative output as well as the quantity of output.



While we occasionally hear of complaints by users that Expressions are slow, the very vast majority of such complaints come from occasional coders, at best.






Their issues can usually be tracked down to poor code which includes using the wrong algorithm or methodology or hitting one or more bottlenecks in other areas of After Effects or a combination of both. And they could also under-appreciate the type of application After Effects is and they proceed to draw up poorly defined comparisons.



So, the next time someone complaints that After Effects Expressions being slow, it should be clear that the actual thing they are saying is very different than what they intended.



So, let's dig in a little. This article is indeed, little but its purpose is to inculcate knowledge in an important area; with the purpose of providing confidence into early adopters and average practitioners of After Effects Expressions.








1. What is a Function in After Effects Expressions?

Think of a function as a self-contained tool or one or more sets of calculations within an Expression. You can use it directly by name to get a result or perform an action.



In After Effects, you have User-defined Functions and Global/Built-In Functions.



User-Defined Functions: You can create your own reusable blocks of code inside your expression.



Built-in Global Functions:

After Effects provides many ready-to-use functions like linear(), ease(), wiggle(), radiansToDegrees(), timeToFrames(). You call these directly too.







// Use the built-in linear() function

opacityValue = linear(time, 0, 1, 0, 100); // Called directly by name

opacityValue



// Define a function to keep a value within 0-100

function clampToPercent(val) {

  return clamp(val, 0, 100);

}


// Invoke the function, clampToPercent(val)


myValue = effect("Slider Control")("Slider").value;


result = clampToPercent(myValue); // Called directly by name


result






2. What is a Method in After Effects Expressions?

A method is a specialized tool (a method is actually a type of function :-)) that is attached to a specific After Effects object, like a Layer, a Composition, or a Property (like Position, Scale, or an Effect Slider).


You use a method to perform an action on that specific object or get information from it.


Objects in AE: Layers (thisLayer, thisComp.layer("My Layer")), Compositions (thisComp), and Properties (position, scale, effect("Slider Control")("Slider")) are all treated as objects.



Method Examples:

Getting a property's value at a specific time:

// 'position' is a Property object

// '.valueAtTime()' is a METHOD called ON the position property

pastPosition = position.valueAtTime(time - 1);

pastPosition




Finding a layer within the composition:


// 'thisComp' is the Composition object

// '.layer()' is a METHOD called ON the comp object

// 'position' is a Property object


otherLayer = thisComp.layer("Background").position;


otherLayer








Getting the velocity of a property:


// 'opacity' is a Property object

// '.velocityAtTime()' is a METHOD called ON the opacity property


currentVelocity = opacity.velocityAtTime(time);


currentVelocity







3. Identifying the Differences in After Effects:


The main difference lies in how you call them and what they are attached to:



Invocation (Function):

Functions (like clamp, linear, ease) are called directly by their name: functionName(arguments).




Methods (like .valueAtTime, .layer, .velocityAtTime) are called using a dot (.) after an object or property: objectOrProperty.methodName(arguments).




Association (Method):

Methods belong to specific After Effects items (Layer, Comp, Property).



The method .valueAtTime() only makes sense when called on a specific property like position or scale.




Functions like linear() or your custom clampToPercent() exist independently and aren't inherently tied to one specific layer or property (though they might use layer or property values you pass into them).




Context - (thisLayer, thisComp):

After Effects provides keywords like thisLayer and thisComp that act like the object context.




Methods often implicitly work on the object they are attached to (e.g., position.valueAtTime() inherently knows to get the value of that position property.




Standalone functions don't automatically know about thisLayer unless you explicitly use it within them like this - thisLayer.inPoint.




If you call a function using objectName.something(), then something() is a method acting on objectName. If you call it just using something(), it's a function.





The author, Roland Kahlenberg has 27 years' experience using Adobe After Effects and has lectured Undergraduate and Post-Graduate students at Nanyang Technological University and has over a thousand hours of experience training fellow professionals.


Roland received his first Adobe After Effects expert certification in 2001. He is also a BorisFX Mocha Certified Trainer and a Dataclay Templater Affiliate Partner.


Roland is a member of the Adobe Video Solutions Partner Program.




If you want a look-in, into the state-of-the-moment, bespoke Scalable and Automated Video Workflows, here are a couple of Youtube Playlists -



Samples of Intelligent Design Assets (IDAs). These are Responsive Designs that can be scaled with Dynamic Content and can be quickly incorporated as part of an Automated Workflow.






Coursework Samples - Develop Advanced Intelligent Design Assets for Motion Graphics Systems


 
 
 

Comments


bottom of page