Logic and Grammar
There are two keys to an understanding of expressions:
- You must understand the solution you are pursuing in a methodical, step-by-step fashion.
- You must translate this ordinary language methodology to the logic and syntax of expressions, to lines of code.
Expressions do only one thing: translate data values. Granted, that's a little bit like saying your computer's hard drive only has ones and zeros on it, but fundamentally, there are three types of data on which expressions do their work:
- Numbers
- Booleans (True/False or Yes/No)
- Text strings (and text hardly comes into play; After Effects is mostly about numbers)
Expressions can either
- Link to existing values found among data in After Effects
- Fabricate new data using criteria that you, the user, specify
Numerical and logic data can come from almost anywhere in the world of After Effects. They can derive from
- Basic transform data of a layer
- Current time in the composition
- The index number of a layer (its order in the composition)
- Dimensions and duration of the source composition or footage
- Either/or conditions about the layer, such as whether it has a parent
Essentially every piece of numerical or Boolean data that exists in your After Effects project is accessible to expressions and can be used to create animations.
Notes
The After Effects expressions language is based on JavaScript (or, more precisely, ECMAscript, the standardized version), a scripting language that was originally devised for Web browsers at Netscape. Many functions that are fundamental to JavaScript, such as the ability to perform mathematical operations, work identically in After Effects. Of course, many other functions from JavaScript are specific to the Web and interactivity. Likewise, After Effects adds its own keywords, functions, and attributes; these use the same basic syntax and rules of JavaScript but would not be recognized by it.
What Can't Expressions Do?
Expressions cannot natively evaluate certain types of data:
- Pixel values
- Audio waveforms
- Mask data
Nor can they handle certain complex effects data, such as effects channels that can be keyframed but whose keyframe values are not made up of four or fewer numerical values. For example, expressions work with RGBA datared, green, blue, and alpha channel values normalized between 0 and 1but they can't handle the Channel Range color control in Hue/Saturation.
Therefore although you can change the pixel values and audio levels of a layer using expressions, you can't sample a given pixel's RGB values, the decibel level of a soundtrack, or the position of a mask point.
Expressions are also only ever aware of conditions at the current point in time. You can create expressions that create a progression over time, but every frame up to the current one has to be recalculated from scratch on each frame, causing the expression to run more and more slowly over time. This can make physical simulations (such as the motion of a spring or the progression of a pattern) impractical.
Muting Keyframes
|