173
Examples
This section describes sample scripts that are included on your DVD, giving an overview of what they do and
a description of how they work.
This set of examples is by no means exhaustive, but it does demonstrate some of scripting’s more complex
features in action. It also shows some typical programming constructions from JavaScript that apply to
scripting.
For more examples from Adobe and from other After Effects users, visit Adobe Studio Exchange at
http://share.studio.adobe.com
, and choose Script in the Adobe After Effects section.
Save and increment
This script,
s a v e _ a n d _ i n c r e m e n t . j s x
, automatically saves a new copy of the open After Effects project and
increments a three-digit number in its name to distinguish it from previous versions of the project.
Note: Although much of the functionality of this script has been superseded by the incremental save feature that was
introduced in After Effects 6.5, it is still included here because it makes effective use of conditionals, functions, and
the ExtendScript File object.
This script does the following:
•
Determines whether the currently open project has ever been saved. If the project has not been saved, pops
up an alert telling the user to save the project, and ends.
•
If the project has been saved at least once before, defines variables for the name of the file and the numbering
and file extension that we plan to add to it.
•
Checks to see if there is an underscore character four characters from the end of the current file name. If
there is, assume that the incrementer has run before and increment the current numerical string, then
extract the name without the numerical extension.
•
An incrementer loop tests for whether the numbering has extended to two or three digits (for example, if
the numbering has reached “_010” or above, or “_100” or above), assigning a zero for each if not.
•
Creates a new file using the updated name and extension, and displays an alert letting the user know the new
file name being saved.
•
Saves the project with the new file name.
Summary of Contents for 65009963 - After Effects CS4
Page 1: ...SCRIPTING GUIDE...