Logic and Grammar, in that Order


There are only two components to learning how to use expressions:

  • You must be able to reason out 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 into lines of code.

Expressions really 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 it's useful to think of this.

Fundamentally, there are three types of data with which expressions work:

  • Numbers

  • Booleans (True/False or Yes/No)

  • Text strings

Expressions can either link to these values where they are found among data in After Effects or fabricate the data using criteria that you, the user, specify. And generally, text is used as only a label for a layer or effect, not as an input/output valueso text almost doesn't count.

So where do these numbers come from? Almost anywhere. They can derive from the basic transform data (position, rotation, scale, opacity, anchor point) of a layer, the current position on the timeline, the number in which the layer appears in the composition, the pixel dimensions of the source footage, whether or not a layer has a parent, and on and on. Pretty much 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.

Okay, What Can't Expressions Do?

Expressions cannot 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.

Creative Accounting

There are, of course, workarounds to the limitations of expressions. The commonly used Levels effect, for example, has an Individual Controls version that was created expressly (pun intended) for use with expressions.

For sampling sound, Trapcode (www.trapcode.com) offers Sound Keys, which can translate waveforms into numerical data suitable for expressions.

As for such unreachable data as mask vertices, it is theoretically possible to sample and adjust them using scripting. I've just never known anyone geeky enough to try it.


So, 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.

One other major limitation is that expressions are incapable of compounding data over time. In other words, calculations that involve a progression from frame to frame cause expressions to recalculate all frames prior to the current one as each new frame is loaded; in such cases, the further you get down the timeline, the longer frames require to render. For example, in After Effects 5.5 Magic (New Riders Publishing), I demonstrated drawing a spirograph shape over time using the Write On effect to add a series of dots to make a line. Each successive dot took longer to calculate its position than the one previous, because it had to know the positions of all of the dots up to that point to know what came next. If that still sounds confusing, don't worry about it; until you find yourself writing an expression that increments with time, you won't likely run up against it.



Adobe After Effects 6. 5 Studio Techniques
Adobe After Effects 6.5 Studio Techniques
ISBN: 0321316207
EAN: 2147483647
Year: 2006
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net