Adobe AFTER EFFECTS 5.5 Help Manual page 400

Table of Contents

Advertisement

Adobe After Effects Help
Using Help
|
Contents
Getting a random value that doesn't depend on time
Using the seed_random() function, you can now write an expression calling for a random
value that depends on the layer's index (number) and the stream (property) but not the
time. For example, the following expression passes true as the second parameter to the
seed_random() function to get a random number between 0 and 1 which depends on the
layer and property number but not the time:
seed_random(<any number>, true);
r = random()
Using the ".name" attribute
After Effects 5.5 adds the expression ".name" to Comp, Footage, Layer, Mask, and Effect
objects. This is useful when you want to apply the same expression to several layers,
varying the behavior based on the name of an object. For example, the following
expression wiggles the position of a layer differently depending on whether or not the
layer is named "hero":
amp = 20;
if (name == "hero") {
amp = 40;
}
wiggle(5, amp)
Accessing keyframes and markers in expressions
You can now write expressions that access keyframes and markers. These expressions are
useful for accessing values at particular times as delineated by keyframe and marker
locations and values. Access keyframes or markers using the following attributes and
methods:
this_comp.marker(marker_num) Returns the time of a composition marker. You can
use this to fade out a layer's opacity at the time where the marker resides—for example:
mark_time = this_comp.marker(1);
linear(time, mark_time - .5, mark_time, 100, 0)
num_keys Returns the number of keyframes in a property.
nearest_key(time) Returns the keyframe object nearest to a designated time.
key(idx) Returns the keyframe by number. For example, key(1) returns the first key.
When you access a key object, you can get time, index, and value properties from it. For
example, the following expression gives you the value of the third position key:
position.key(3).value
The following expression, when written on a layer's animated Opacity property, ignores
the keyframe values and only uses the keyframes' placement in time to determine where a
flash should occur:
d = Math.abs(time - nearest_key(time).time);
ease_out(d, 0, .1, 100, 0)
Using Help
|
Contents
|
Index
|
Index
(5.5) Expressions
Back
400
Back
400

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents