Object References from Scratch
Weve covered the basics of creating simple expressions with the pick whip. There are times, however, when you cant or dont want to use the pick whip. You cannot, for instance, drag the whip to any element not currently visible onscreen, or to attributes such as width or frame_duration (because they don't appear onscreen).
An object is just a container. Each object can contain other objects, attributes or methods.
For instance, a comp is a kind of object in After Effects. Each comp can contain other objects, such as layers, or attributes such as duration or width. (Well discuss methods later.) All of the After Effects elements youre familiar with comps, layers, opacity, etc either are objects or are contained by objects.
Because objects can contain other objects, locating the element youre after can involve a series of object identifiers. You should think in terms of hierarchy: start with the largest container and work towards the smallest. In slightly more technical terms, you will always start with a global object.
To identify a property to take data from, you must first start by identifying a global object.
A global object is simply an object that can be referred to without any introduction, anywhere in your expression. Other objects --- the non-global ones live inside global objects (or inside objects that are inside global objects) and can only be accessed by first naming the objects which contain them.
It may help to think for a minute about street addresses. You cannot, for instance, address a letter to 100 Main St. and leave it at that. There must be thousands of Main Streets in the US, and the postal service would have no idea which you meant. So, at the very least, youd need to identify which city your Main St. could be found in. Youd also need to specify the state. If you were overseas, youd even need to specify the country. You dont need to go further than the country, because they dont need any introduction theyre not contained by anything except the Earth itself. Countries therefore can be considered global objects.
So, in After Effects, you always need to start with a global object, just like when you address a letter. After Effects global objects include:
After youve identified a global object, youll probably want to specify some attribute, method or sub-object belonging to it. But how do you know what your choices are? Whats inside the global object youve chosen? You can find this information in the tables Ive provided here, or in the expressions language reference part of the After Effects User Guide.
First, you need to find out what kind of object you actually have that is, what kind of object is returned by the specifier youve chosen. For instance, this_comp returns a comp object (surprise!). Then, you can look in the reference material to see what objects of that type contain. In this example, wed see that comp objects contain layer objects and attributes such as width or duration (among many other elements).
So, after specifying this_comp, we could choose a particular layer within the current comp:
This will return the layer named Solid 1 in the current comp. We could stop here, if we just needed a layer object. Since we typically need a value or vector, however, we probably would repeat the above process, this time looking up what objects, attributes and methods are contained by layer objects.
Notice also that there are no spaces in object specifiers, except when referring to item names, in quotation marks.
Now that we have a layer object, well identify an attribute or method we want to use. For instance:
Again, a period separates the object and its attribute.
If you ever have trouble with this syntax, you can always let the pick whip help you. Simply put the text cursor at the spot in your expression where you need the object reference, and then drag the pick whip to the object or attribute you need. After Effects will automatically insert the correct object reference. You can drag the pick whip to other windows, including even the Project window.
In addition to the properties we listed earlier, layer objects contain the following attributes or methods:
This list is not exhaustivelook in the tables Ive provided here or in the After Effects User Guide for more information. The list is included here only to show that layer attributes can return a wide variety of objects, including even other comps. You could easily have an object reference that looked like:
this_comp.layer("Nested Comp").source.layer("Solid 1").position
Entire contents © 2001 JJ Gifford.