Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Adobe After Effects 7.0 - Guía de Secuencias de Comandos PDF
Adobe After Effects 7.0 - Guía de Secuencias de Comandos PDF
de After Effects
bc
Introduccin
La Gua de secuencias de comandos de After Effects muestra cmo obtener un control de los procedimientos de
los proyectos de After Effects mediante secuencias de comandos. Este conjunto de funciones est disponible
nicamente en Adobe After Effects 7.0 Professional Edition.
Mediante las secuencias de comandos del sistema, puede simplificar la canalizacin de procesos y evitar tener
que seleccionar y hacer clic repetidamente. Si ha utilizado expresiones u otras tcnicas similares a JavaScript
para la animacin, o ha trabajado con secuencias de comandos del sistema en AppleScript o Visual Basic,
reconocer la eficacia de las secuencias de comandos en After Effects. Con prctica y experiencia suficiente en
el lenguaje JavaScript, podr controlar la canalizacin de los grficos.
Automatizacin de procesos
Uno de los usos principales de las secuencias de comandos en After Effects 7.0 es la automatizacin de procesos.
Interesar a cualquier persona responsable de administrar una canalizacin de procesos compleja.
La automatizacin de procesos se puede llevar a cabo mediante secuencias de comandos codificadas
manualmente o mediante una solucin de procesamiento en red de terceros que admita la administracin
automatizada de las canalizaciones de procesos en red.
Adems de las soluciones de secuencias de comandos, After Effects proporciona una herramienta de lnea de
comandos para la automatizacin de procesos. Esta herramienta, a eren der, permite procesar composiciones
desde la lnea de comandos, sin pasar por la interfaz de usuario de After Effects. Para obtener informacin de
referencia completa sobre esta herramienta, consulte Render Automation Command en la pgina 207.
Introduccin
Tambin puede aprovechar la contribucin de usuarios que comparten secuencias de comandos con otros
usuarios. Los grandes estudios pueden tener a estos usuarios en plantilla, mientras que otros usuarios pueden
visitar foros como los que encontrar en
w w w. a dob efor u m s . com .
Introduccin
Las secuencias de comandos reproducen gran parte de lo que se puede hacer mediante la interfaz de usuario
de After Effects, por lo que es fundamental tener un slido conocimiento de la aplicacin para saber cmo
utilizar esta funcionalidad.
NOTA: Los objetos de JavaScript llamados normalmente propiedades reciben el nombre de atributos en esta
gua para evitar la confusin con la propia definicin de una propiedad en After Effects (un valor que se puede
animar de un efecto, mscara o transformacin en una capa individual).
Cuando utiliza Adobe After Effects, crea proyectos, composiciones y elementos de la cola de procesamiento
junto con todos los elementos que contienen: material de archivo, imgenes, slidos, capas, mscaras, efectos
y propiedades. En trminos de secuencia de comandos, cada uno de estos elementos es un objeto.
El ncleo de una aplicacin de secuencia de comandos es el modelo de objetos. En After Effects, el modelo
de objetos est formado por un proyecto, elementos, composiciones, capas y elementos de la cola de
procesamiento. Cada objeto tiene sus atributos especiales y cada objeto de un proyecto de After Effects
tiene una identidad propia (aunque no todos se pueden utilizar con secuencias de comandos).
Debe estar familiarizado con el modelo de objetos de After Effects para poder crear secuencias de comandos.
Si desea conocer ms recursos para aprender a utilizar secuencias de comandos, consulte Ms recursos para
aprender a utilizar secuencias de comandos en la pgina 9.
notas integrado (asegrese de definir la codificacin como UTF-8 en las opciones de guardar).
Entre las aplicaciones de Mac OS tiles para editar secuencias de comandos se incluyen BBEdit o la
aplicacin integrada OS X TextEdit (asegrese de definir el tipo de almacenamiento como Unicode [UTF8] en las preferencias).
operativos, Adobe ExendScript define los objetos F i l e y Fo l der para proporcionar un acceso independiente de
la plataforma al sistema de archivos subyacente.
Mdulo de interfaz de usuario ScriptUI: El mdulo ScriptUI de ExtendScript permite crear e interactuar con
elementos de la interfaz de usuario. ScriptUI proporciona un modelo de objetos para ventanas y elementos de
control de UI en una aplicacin de Adobe.
NOTA: After Effects no admite la personalizacin de la funcin de diseo automtico de ScriptUI.
Herramientas y utilidades: Adems, ExtendScript ofrece herramientas y funciones, como una utilidad de
traduccin que proporciona valores de cadenas de la interfaz de usuario en distintos idiomas y funciones
globales para mostrar mensajes cortos en cuadros de dilogo (a l er t , con fi r m y prom p t ).
Comunicacin entre aplicaciones: ExtendScript proporciona un entorno de secuencias de comandos comn
para todas las aplicaciones de Adobe y permite la comunicacin entre aplicaciones mediante secuencias de
comandos.
Estas funciones se describen en detalle en Bridge JavaScript Reference, disponible con After Effects.
Los archivos de secuencias de comandos de ExtendScript se diferencian por la extensin . j s x , una variacin de
la extensin estndar . j s utilizada con los archivos de JavaScript. Las secuencias de comandos de After Effects
deben incluir la extensin de archivo . j s x para que la aplicacin las reconozca correctamente. Cualquier
archivo de texto codificado con UTF-8 que tenga la extensin . j s x se reconocer como un archivo de
ExtendScript.
Las secuencias de comandos guardadas en la carpeta Shutdown se ejecutan cuando se cierra la aplicacin. Esto
se produce despus de cerrar el proyecto pero antes de que se cierre otra aplicacin.
Cmo incluir secuencias de comandos de After Effects en una lnea de comandos (Windows)
A continuacin se indican algunos ejemplos de entradas de la lnea de comandos de Windows que envan una
secuencia de comandos de After Effects a la aplicacin sin utilizar la interfaz de usuario de After Effects para
ejecutarla.
En el primer ejemplo, se copia y pega la secuencia de comandos de After Effects directamente en la lnea
de comandos y despus se ejecuta. El texto de la secuencia aparecer entre comillas despus del comando
a f ter f x . exe s :
a f ter f x . exe s " a l er t ( " Ac a b a de env i a r u n a a l er t a a Af ter E f fe c t s " ) "
Tambin puede especificar la ubicacin del archivo JSX que se va a ejecutar. Por ejemplo:
a f ter f x . exe r c : \ m i s D o c u m en to s \ S c r i p t s \ su A E S c r i p t Here . j s x
a f ter f x . exe r " c : \ m i s D o c u m en to s \ S c r i p t s \ Nom bre de S c r i p t con S p a ce s . j s x "
Tambin puede mostrar un cuadro de dilogo que pida la ubicacin del archivo JSX que se va a ejecutar,
de la siguiente manera:
s e t t h e F i l e to ch o o s e fi l e
te l l a pp l i c a t i on " Adob e Af ter E f fe c t s 7 . 0 "
DoScript theFile
en d te l l
Por ltimo, esta secuencia de comandos es quiz la ms til cuando se trabaja directamente en la edicin de
una secuencia de comandos JSX y se desea enviarla a After Effects para probarla o ejecutarla. Para utilizarla de
manera eficaz, debe especificar la aplicacin que contiene el archivo JSX abierto (en este ejemplo, TextEdit);
si no sabe el nombre exacto de la aplicacin, escriba lo ms parecido a TextEdit y AppleScript le pedir que
la busque.
Basta con que resalte el texto de la secuencia que desea ejecutar y, a continuacin, active este AppleScript:
(*
E s t a s e c u en c i a de com a n do s env a l a s e l e cc i n a c tu a l a Af ter E f fe c t s com o u n a s e c u en c i a de com a n do s .
*)
te l l a pp l i c a t i on Tex t E d i t
s e t t h e _ s c r i p t to s e l e c t i on a s tex t
en d te l l
te l l a pp l i c a t i on " Adob e Af ter E f fe c t s 7 . 0 "
a c t iv a te
DoScript the_script
en d te l l
Para obtener ms informacin sobre cmo utilizar AppleScript, consulte AppleScript: the Definitive Guide de
Matt Neuberg (OReilly & Associates) o AppleScript 1-2-3 de Sal Soghoian (Peachpit Press).
10
Table 1
Palabra clave/instruccin
Descripcin
bre a k
con t i nu e
case
def a u l t
Etiqueta que se utiliza en una instruccin s w i tch cuando no se encuentra una etiqueta c a s e .
do. . . w h i l e
false
for
for. . . i n
Construccin estndar de JavaScript. Proporciona una manera de desplazarse fcilmente por las
propiedades de un objeto.
f u n c t i on
if/if...else
n ew
nu l l
Se asigna a una variable, elemento de conjunto o propiedad de objeto para indicar que no
contiene un valor vlido.
re tu r n
Forma estndar de JavaScript de devolver un valor de una funcin o salir de una funcin.
s w i tch
this
true
u n defi n e d
var
Sintaxis estndar de JavaScript que se utiliza para declarar una variable local.
while
with
Construccin estndar de JavaScript que se utiliza para especificar un objeto que se va a utilizar
en instrucciones posteriores.
10
11
Operadores
En las siguientes tablas se enumeran y se describen todos los operadores que reconoce el motor de secuencia
de comandos de After Effects, y se indica la prioridad y la asociatividad de todos ellos.
Table 2
Operadores
Descripcin
n ew
Asigna un objeto.
de l e te
t y p e of
voi d
[]
()
++
NOT lgico.
Multiplicar.
Dividir.
Divisin modular.
Sumar.
<<
>>
>>>
<
Menor que.
<=
>
Mayor que.
>=
==
Igual.
!=
Distinto.
&
OR bit a bit.
&&
AND lgico.
||
OR lgico.
11
12
Operadores
Descripcin
?:
Condicional (ternario).
Asignacin.
+=
*=
/=
%=
<<=
>>=
>>>=
&=
^=
|=
Evaluacin mltiple.
Table 3
Asociatividad
[], (), .
izquierda a derecha
n ew, de l e te , ( n e g a c i n u n a r i a ) , ! , t y p e of , voi d , + + ,
derecha a izquierda
*, /, %
izquierda a derecha
+ , ( re s t a )
izquierda a derecha
izquierda a derecha
izquierda a derecha
==, !=
izquierda a derecha
&
izquierda a derecha
izquierda a derecha
izquierda a derecha
&&
izquierda a derecha
||
izquierda a derecha
?:
derecha a izquierda
derecha a izquierda
izquierda a derecha
12
JavaScript Reference
This chapter lists and describes JavaScript classes, objects, methods, attributes, and global functions defined by
After Effects.
The After Effects scripting engine supports ExtendScript, Adobes extended version of JavaScript, which implements the 3rd Edition of the ECMA-262 Standard, including its notational and lexical conventions, types,
objects, expressions and statements. For a complete listing of the keywords and operators included with
ECMAScript, refer to E C M A- 2 6 2 .p d f , available at w w w. e cm a - i n ter n a t ion a l . o r g / p u b l i ca t i on s/ s ta n d a rds /
E c ma-26 2.h t m . For an overview of the most common keywords and statements available from ECMA-262, see
Keywords and statement syntax on page 9.
APPLICATION
SETTINGS
FOLDER
SOCKET
ITEMS MAY BE ANY OF THE FOLLOWING TYPES OF ITEM
PROJECT
COMP)TEM
RENDER1UEUE
FILE
/2
/2
FOOTAGE)TEM
FOLDER)TEM
ITEMS
LAYERS
ITEMS
PROXY3OURCE
RENDER1UEUE)TEMS
PROPERTIES
MAIN3OURCE
PROXY3OURCE
MAIN3OURCE PROXY3OURCE
MAY BE ANY OF THE FOLLOWING TYPES OF ITEM
OUTPUT-ODULES
SOLID3OURCE
COLOR
/2
PLACEHOLDER3OURCE
/2
FILE3OURCE
FILE
Note that the File and Folder objects are defined by ExtendScript, and are documented in the Bridge JavaScript
Reference. The Socket object is defined by ExtendScript, and is documented in The Socket Object on
page 201.
ExtendScript also defines the ScriptUI module, a set of window and user-interface control objects, which are
available to After Effects scripts. These are documented in the Bridge JavaScript Reference.
13
JavaScript Reference
14
The hierarchy of objects in scripting corresponds to the hierarchy in the user interface.
The application contains a Project panel, which displays a project. The project contains compositions, which
contain layers. The source for a layer can be a footage file, placeholder, or solid, also listed in the Project panel.
Each layer contains settings known as properties, and these can contain markers and keyframes. The render
queue contains render-queue items as well as render settings and output modules. All of these entities are represented by objects in scripting.
NOTE: To avoid ambiguity, this manual uses the term attribute to refer to JavaScript object properties, and the
term property or AE property to refer to After-Effects layer properties.
Object summary
The following table lists all objects alphabetically, with links to the documentation page for each.
Object
Description
Globally available functions that allow you to display text for script debugging purposes,
and help convert time values between seconds and frames.
A single global object, available by its name (a pp ), that provides access to objects and
application settings within the After Effects application.
Represents those layers that contain AVItems (Comp layers, footage layers, solid layers,
text layers, and sound layers).
14
JavaScript Reference
15
Object
Description
Associates a set of objects or values as a logical group and provides access to them by
index.
Represents a composition, and allows you to manipulate it and get information about it.
Represents a footage item imported into a project, which appears in the Project panel.
A base class for After Effects property and property group classes.
15
JavaScript Reference
16
Global functions
These globally available functions that are specific to After Effects. Any JavaScript object or function can call
these functions, which allow you to display text in a small (3-line) area of the Info panel, and to convert
numeric time values to and from string values.
Global function
Description
w r ite( )
w r ite L n ( )
Writes text to the Info panel, adding a line break at the end.
cl e arO ut put ()
c u r re n t Fo r m a t To Ti m e ( )
Additional global functions for standard user I/O (aler t , con fi r m , and prom pt ) and static functions for file
I/O, are defined by ExtendScript; for detailed reference information, see the Bridge JavaScript Reference.
NOTE: The After Effects global functions for standard dialogs and file I/O are still supported in this release, but
are deprecated and will not be supported in future releases. For details, see the After Effects 6.5 documentation.
None.
Returns
Nothing.
Converts a formatted string for a frame time value to a number of seconds, given a specified frame rate. For
example, if the formatted frame time value is 0:00:12 (the exact string format is determined by a project
setting), and the frame rate is 24 fps, the time would be 0.5 seconds (12/24). If the frame rate is 30 fps, the time
would be 0.4 seconds (12/30).
If the time is a duration, the frames are counted from 0. Otherwise, the frames are counted from the projects
starting frame (see Project displayStartFrame attribute on page 106).
Parameters
for m at ted Tim e
The frame time value, a string specifying a number of frames in the projects current time display format.
fps
16
JavaScript Reference
17
i s D u r a ti o n
Optional. When true, the time is a duration (measured from frame 0). When false (the default), the time is
measured from the projects starting frame.
Returns
Converts a numeric time value (a number of seconds) to a frame time value; that is, a formatted string that
shows which frame corresponds to that time, at the specified rate. For example, if the time is 0.5 seconds, and
the frame rate is 24 fps, the frame would be 0:00:12 (when the project is set to Display Timecode). If the frame
rate is 30 fps, the frame would be 0:00:15. The format of the timecode string is determined by a project setting.
If the time is a duration, the frames are counted from 0. Otherwise, the frames are counted from the projects
starting frame (see Project displayStartFrame attribute on page 106).
Parameters
time
fps
i s D u r a ti o n
Optional. When true, the time is a duration (measured from frame 0). When false (the default), the time is
measured from the projects starting frame.
Returns
The string to display. Truncated if too long for the Info panel.
Returns
Nothing.
Example
w r ite ( " T h i s text ap p e a r s i n In fo p a n e l ") ;
w r ite ( " w it h m o re o n s a m e l i n e . " ) ;
17
JavaScript Reference
18
Writes output to the Info panel and adds a line break at the end.
Parameters
tex t
Returns
Nothing.
Example
w r ite l n ( " T h is tex t a pp e ars on f i r s t l i n e " ) ;
w r ite l n ( " T h is tex t a pp e ars on s e con d l i n e " );
18
JavaScript Reference
19
Application object
a pp
Description
Provides access to objects and application settings within the After Effects application. The single global object
is always available by its name, a pp .
Attributes of the Application object provide access to specific objects within After Effects. Methods of the
Application object can create a project, open an existing project, control Watch Folder mode, purge memory,
and quit the After Effects application. When the After Effects application quits, it closes the open project,
prompting the user to save or discard changes as necessary, and creates a project file as necessary.
Attributes
Attribute
Reference
Description
proj ec t
language
vers i on
s e r i a l Nu m b e r
Application serialNumber attribute on The serial number of the After Effects installation.
page 29
re g i s tere d Na m e
Application registeredCompany
attribute on page 28
b u i l dNa m e
b u i l dNu m b e r
i s Prof e s si o n a l Ver si o n
Application isProfessionalVersion
attribute on page 24
i s Wa tch Fo l der
i s Ren d e r E n g i n e
s e tt i n g s
o n E r ror
e x i t Cod e
e xi t Af ter L a u n ch A n d Eva l
Application exitAfterLaunchAndEval
attribute on page 23
19
JavaScript Reference
20
Attribute
Reference
Description
s avePro je c t On Cr as h
Application saveProjectOnCrash
attribute on page 28
Methods
Method
Reference
Description
newPro jec t ()
open()
qui t ()
w atch Fo l der ( )
p au se Wa tchFol de r ()
endWatch Folder()
p u r g e ()
b eg i nUndoGroup()
endUndoGroup()
b eg i nSup pres sD i al o g s( )
Application beginSuppressDialogs()
method on page 21
e n d Su p p re s s D i a l o g s( )
Application endSuppressDialogs()
method on page 22
Application setMemoryUsageLimits()
method on page 29
Application setSavePreferencesOnQuit()
method on page 30
a c t iva te( )
Application activate() method on page 20 Brings the After Effects main window to the
front of the screen.
s ch e dul e Tas k( )
c a n ce l Tas k( )
Opens the application main window if it is minimized or iconified, and brings it to the front of the desktop.
Parameters
None.
20
JavaScript Reference
21
Returns
Nothing.
Begins suppression of script error dialog boxes in the user interface. Use en dSuppres s D ia l og s () to resume the
display of error dialogs. See Application endSuppressDialogs() method on page 22.
Parameters
None.
Returns
Nothing.
Marks the beginning of an undo group, which allows a script to logically group all of its actions as a single
undoable action (for use with the Edit > Undo/Redo menu items). Use the endUndoGrou p() method to mark
the end of the group. (See Application endUndoGroup() method on page 22.)
b eg i nUndoGroup() and endUn doGrou p() pairs can be nested. Groups within groups become part of the
larger group, and will undo correctly. In this case, the names of inner groups are ignored.
Parameters
u n d o S t r in g
The text that will appear for the Undo command in the Edit menu (that is, Undo < un do St r i n g > )
Returns
Nothing.
The name of the build of After Effects being run, used internally by Adobe for testing and troubleshooting.
Type
String; read-only.
21
JavaScript Reference
22
The number of the build of After Effects being run, used internally by Adobe for testing and troubleshooting.
Type
Integer; read-only.
Removes the specified task from the queue of tasks scheduled for delayed execution.
Parameters
t as kI D
Returns
Nothing.
Ends the suppression of script error dialog boxes in the user interface. Error dialogs are displayed by default;
call this method only if b eg i nSu ppres sD i al o g s( ) has previously been called. See Application beginSuppressDialogs() method on page 21.
Parameters
a l er t
Boolean; when true, errors that have occurred following the call to b e g i nSup pres sD i al o g s( ) are displayed in a
dialog box.
Returns
Nothing.
Marks the end of an undo group begun with the app.be g i nUndoGro up() method. You can use this method
to place an end to an undo group in the middle of a script, should you wish to use more than one undo group
for a single script.
If you are using only a single undo group for a given script, you do not need to use this method; in its absence
at the end of a script, the system will close the undo group automatically.
22
JavaScript Reference
23
Calling this method without having set a b e g i n Un d o Grou p ( ) method yields an error.
Parameters
None.
Returns
Nothing.
None
Returns
Nothing.
See also
This attribute is used only when executing a script from a command line on Windows. When the application
is launched from the command line, the r or s command line flag causes the application to run a script
(from a file or from a string, respectively).
If this attribute is set to true, After Effects will exit after the script is run; if it is false, the application will remain
open.
This attribute only has an effect when After Effects is run from the Windows command line. It has no effect
in Mac OS.
Type
Boolean; read/write.
23
JavaScript Reference
24
A numeric status code used when executing a script externally (that is, from a command line or AppleScript).
In Windows, the value is returned on the command line when After Effects was launched on the commands
line (using the af ter f x or af tger fx m command), and a script was specified with the r or s option.
in Mac OS, the value is returned as the Applescript D oS c r i p t result for each script.
In both Mac OS and Windows, the value is set to 0 (E X I T _ S UC C E S S ) at the beginning of each script evaluation. In the event of an error while the script is running, the script can set this to a positive integer that
indicates what error occured.
Type
Integer; read/write.
Example
a pp. ex i tCo de = 2 ; / / on qui t, i f v a lue is 2, a n er ror ha s o ccu r re d
True if the locally installed After Effects application is the Professional Edition, false if it is the Standard
Edition.
Type
Boolean; read-only.
Example
v ar P B = a p p.i s Pro f e s s i o n a lVer s i o n ;
a l er t( "It i s " + P B + " tha t you are r unn ing the Prof es si onal Ed i t i on .") ;
Boolean; read-only.
24
JavaScript Reference
25
True if the Watch Folder dialog box is currently displayed and the application is currently watching a folder
for rendering.
Type
Boolean; read-only.
Creates a new project in After Effects, replicating the File > New > New Project menu command.
If the current project has been edited, the user is prompted to save it. If the user cancels out of the Save dialog
box, the new project is not created and the method returns null. Use a pp.pro je c t .c lo se (C l os eO p t i o n s. D O_ N OT _ S AVE _ C H A N G E S ) to close the current project before opening a new one. See Project
close() method on page 105.
Parameters
None.
25
JavaScript Reference
26
Returns
The name of a callback function that is called when an error occurs. By creating a function and assigning it to
this attribute, you can respond to errors systematically; for example, you can close and restart the application,
noting the error in a log file if it occurred during rendering. See RenderQueue render() method on page 148.
The callback function is passed the error string and a severity string. It should not return any value.
Type
Opens a project.
Parameters
file
Optional. An ExtendScript File object for the project file to open. If not supplied, the method prompts the
user to select a project file.
Returns
A new Project object for the specified project, or null if the user cancels the Open dialog box.
Example
v ar my _file = new File (". ./my_folder/my_test .a ep");
i f (my _ fi l e . ex i st s) {
n e w _ p ro j e c t = a p p.o p e n ( my _ f i l e ) ;
i f (n e w _ proj e c t) {
a l er t( new _ proje c t.f i le.n ame) ;
}
26
JavaScript Reference
27
Pauses or resumes the search of the target watch folder for items to render.
Parameters
p au se
Returns
Nothing.
See also
The project that is currently loaded. See Project object on page 104.
Type
Purges unused data of the specified types from memory. Replicates the Purge options in the Edit menu.
Parameters
t arg e t
The type of elements to purge from memory; a Pur g eTa rg et enumerated value, one of:
Pur g e Ta r ge t . A L L _ C AC HE S : Purges all data that After Effects has cached to physical memory.
Purg e Tar ge t .UN D O _ C AC H E S : Purges all data saved in the undo cache.
Purg e Tar ge t .S NAP S HOT _ C AC H E S : Purges all data cached as comp/layer snapshots.
Pur g e Ta r ge t . I M AG E _ C AC H E S : Purges all saved image data.
Returns
Nothing.
27
JavaScript Reference
28
None.
Returns
Nothing.
The name (if any) that the user of the application entered as the registered company at the time of installation.
Type
String; read-only.
Example
v ar comp any = ap p.re g is tered Comp any ;
a l er t ( Yo ur com p a ny n a m e i s + com p a ny + . ) ;
The user name, if any, that the user of the application entered for the registered name at the time of installation.
Type
String; read-only.
Example
v ar userNam e = a pp.reg i stere d Na me;
con f i r m ( Are you + u s e r Na m e + ? ) ;
When true (the default), After Effects attempts to display a dialog box that allows you to save the current
project if an error causes the application to quit unexpectedly. Set to false to suppress this dialog box and quit
without saving.
28
JavaScript Reference
29
Type
Boolean; read/write.
de l ay
rep e at
When true, execute the script repeatedly, with the specified delay between each execution. When false
the script is executed only once.
Returns
Integer, a unique identifier for this task, which can be used to cancel it with ap p.ca nce l Ta sk () .
The alphanumeric string that is the serial number of the installed version of After Effects.
Type
String; read-only.
Example
v ar s er i a l = a pp. ser i al Num b er ;
a l er t ( " T h i s cop y is s e r i a l nu m b e r " + s er i a l ) ;
Sets memory usage limits as in the Memory & Cache preferences area. For both values, if installed RAM is less
than a given amount (n gigabytes), the value is a percentage of the installed RAM, and is otherwise a
percentage of n. The value of n is: 2 Gb for Win32, 4 Gb for Win64, 3.5 Gb for Mac OS.
Parameters
i m a ge Ca chePercen ta g e
m a x im u m Me m o r y Pe rcen t a ge
29
JavaScript Reference
30
Returns
Nothing.
Set or clears the flag that determines whether preferences are saved when the application is closed.
Parameters
doS ave
When true, preferences saved on quit, when false they are not.
Returns
Nothing.
String; read-only.
Example
v ar ver = a p p. vers i o n ;
a l er t( " T h i s m a chi n e is r un n in g versi o n " + ver + " o f Af ter E f fe c t s . " ) ;
30
JavaScript Reference
31
Parameters
fo l de r _ o b j e c t _ to _ wa tch
Returns
Nothing.
Example
v ar t heFolder = new Folder(c: /too l);
a pp. wa tchFolder(theFolder);
See also
31
JavaScript Reference
32
AVItem object
a pp. pro je c t .i tem ( i n d e x)
Description
The AVitem object provides access to attributes and methods of audio/visual files imported into After Effects.
AVItem is a subclass of Item. All methods and attributes of Item, in addition to those listed below, are
available when working with AVItem. See Item object on page 74.
AVItem is the base class for both CompItem and FootageItem, so AVItem attributes and methods are also
available when working with CompItem and FootageItem objects. See CompItem object on page 50 and
FootageItem object on page 62.
Attributes
Attribute
Reference
Description
name
w i dt h
h eig h t
p i xel As p e c t
f r a m eRa te
f r a m eD ur a t i on
AVItem frameDuration attribute on page 33 The frame duration for the item.
du r at i on
u s e Prox y
prox y S ou rce
time
u s e dIn
h as Vi de o
h as Au di o
fo o t ag e M is s in g
Methods
Method
Reference
Description
s e tProxy ( )
s e tProxy ToNon e ( )
AVItem setProxyToNone() method on page 36 Removes the proxy for the item.
32
JavaScript Reference
33
Returns the duration, in seconds, of the item. Still footage items have a duration of 0.
In a CompItem, the value is linked to the d u r a ti o n of the composition, and is read/write.
In a FootageItem, the value is linked to the dur at i on of the m a i n S o u rce object, and is read-only.
Type
Floating-point value in the range [0.0..10800.0]; read/write for a CompItem; otherwise, read-only.
When true, the AVItem is a placeholder, or represents footage with a source file that cannot be found. In this
case, the path of the missing source file is in the m i s s in g Fo o ta g e Pat h attribute of the footage items source-file
object. See FootageItem mainSource attribute on page 63 and FileSource missingFootagePath attribute on
page 58.
Type
Boolean; read-only.
Returns the length of a frame for this AVItem, in seconds. This is the reciprocal of f r a m eRa te . When set, the
reciprocal is automatically set as a new f r am e R a te value.
This attribute returns the reciprocal of the f r am e R a te , which may not be identical to a value you set, if that
value is not evenly divisible into 1.0 (for example, 0.3). Due to numerical limitations, (1 / ( 1 / 0.3) ) is close
to, but not exactly, 0.3.
If the AVItem is a FootageItem, this value is linked to the m a in S o u rce , and is read-only. To change it, set the
con f o r m Fr a m e R a te of the m a i n S o u rce object. This sets both the f r a m e R ate and f r a m e D u r at i o n of the
FootageItem.
Type
Floating-point value in the range [1/99 .. 1.0 ]; read-only for a FootageItem, otherwise read/write.
33
JavaScript Reference
34
The frame rate of the AVItem, in frames-per-second. This is the reciprocal of the f r am e D u r a t ion . When set,
the reciprocal is automatically set as a new f r am e D u r a t ion value.
In a CompItem, the value is linked to the f r a m eRa te of the composition, and is read/write.
In a FootageItem, the value is linked to the f r a m e R ate of the m a i n S o u rce object, and is read-only. To change
it, set the confor mFr ame Rate of the m a i n S o u rce object. This sets both the fr ameR ate and fr ame D ur a ti on
of the FootageItem.
Type
Floating-point value in the range [1.0..99.0]; read-only for a FootageItem, otherwise read/write.
Boolean; read-only.
Boolean; read-only.
34
JavaScript Reference
35
In a FootageItem, the value is linked to the m a i n S o u rce object, and is read/write only if the m a i n S o u rce
value controls the display name in the Project panel, but does not affect the file name.
Type
String; read/write.
Certain p ixel As p e c t values are specially known to After Effects, and are stored and retrieved with perfect
accuracy. These are the set { 1, 0 .9, 1.2, 1.0 7, 1 .42, 2, 0 .95 , 1. 9 } . Other values may show slight rounding
errors when you set or get them; that is, the value you retrieve after setting may be slightly different from the
value you supplied.
Type
The FootageSource being used as a proxy. The attribute is read-only; to change it, call any of the AVItem
methods that change the proxy source: se t Prox y ( ) , s e tProxyWi thS e quence( ) , se t Prox y Wi t hS o l i d () , or
s e t Proxy Wi thP l a ce h o l der ( ) .
Type
35
JavaScript Reference
36
Sets a file as the proxy of this AVItem. Loads the specified file into a new FileSource object, sets this as the value
of the prox y S ource attribute, and sets u se Prox y to true. It does not preserve the interpretation parameters,
instead using the user preferences. If the file has an unlabeled alpha channel, and the user preference says to
ask the user what to do, the method estimates the alpha interpretation, rather than asking the user.
This differs from setting a FootageItem's main source, but both actions are performed as in the user interface.
Parameters
file
Returns
None.
Removes the proxy from this AVItem, sets the value of p roxy S o u rce to null, and sets the value of u se Prox y to
f al s e .
Parameters
None.
Returns
Nothing.
Creates a PlaceholderSource object with specified values, sets this as the value of the prox y S ource attribute,
and sets u s e Prox y to true. It does not preserve the interpretation parameters, instead using the user preferences.
NOTE: There is no direct way to set a placeholder as a proxy in the user interface; this behavior occurs when a proxy
has been set and then moved or deleted.
Parameters
name
w i dt h, heig ht
f r a m eRa te
36
JavaScript Reference
37
du r at i on
Returns
Nothing.
Sets a sequence of files as the proxy of this AVItem, with the option of forcing alphabetical order. Loads the
specified file sequence into a new FileSource object, sets this as the value of the prox y S ource attribute, and sets
u s e Prox y to true. It does not preserve the interpretation parameters, instead using the user preferences. If any
file has an unlabeled alpha channel, and the user preference says to ask the user what to do, the method
estimates the alpha interpretation, rather than asking the user.
Parameters
file
force Alp ha b e t ic a l
Returns
Nothing.
Creates a SolidSource object with specified values, sets this as the value of the prox y S ource attribute, and sets
u s e Prox y to true. It does not preserve the interpretation parameters, instead using the user preferences.
NOTE: There is no way, using the user interface, to set a solid as a proxy; this feature is available only through
scripting.
Parameters
co lor
The color of the solid, an array of 3 floating-point values, [R, G, B], in the range [0.0..1.0].
name
w i dt h, heig ht
p i xel As p e c t
The pixel aspect of the solid, a floating-point value in the range [0.01... 100.0].
Returns
Nothing.
37
JavaScript Reference
38
The current time of the item when it is being previewed directly from the Project panel. This value is a number
of seconds. Use the global method t i m eTo Cur ren t Fo r m at to convert it to a string value that expresses the time
in terms of frames; see timeToCurrentFormat() global function on page 17.
It is an error to set this value for a FootageItem whose m a i n S o u rce is still (ite m .m ai n S ource .i s St i l l is true).
Type
When true, a proxy is used for the item. It is set to true by all the S e t Prox y methods, and to false by the
S e tProx y ToNon e( ) method.
Type
Boolean; read/write.
38
JavaScript Reference
39
AVLayer object
a pp. pro j e c t .l ayer ( i n d e x)
Description
The AVLayer object provides an interface to those layers that contain AVItems (Comp layers, footage layers,
solid layers, text layers, and sound layers).
AVLayer is a subclass of Layer. All methods and attributes of Layer, in addition to those listed below, are
available when working with AVLayer. See Layer object on page 81.
AVLayer is a base class for TextLayer, so AVLayer attributes and methods are available when working with
Different types of layers have different AE properties. AVLayer has the following properties and property
groups:
Ma r ker
Tim e Remap
Mot i on Tr a ckers
Ma sk s
Effects
Tr an s for m
Anchor Point
Pos i t i on
S c al e
Orientation
X Rot at i on
Y Rot at i o n
Rot at i o n
O p a ci t y
Ma ter i al O p t i on s
C as ts S h a dow s
L i g ht Tr a n s m i ss i on
Acce p ts S h a dows
Acce p ts L i g h ts
Ambi ent
D i ff us e
S p e c u l ar
Shininess
Met al
Aud i o
Aud i o Le ve l s
Example
If the first item in the project is a CompItem, and the first layer of that CompItem is an AVLayer, the following
sets the layer qua l it y, s ta r t Ti m e , and i n Poi n t .
v ar f i r s t L aye r = a p p. p ro je c t .i te m ( 1 ) . l ayer (1 ) ;
first L ayer.qu alit y = L ayerQ ualit y.B EST;
f i r s t L aye r. s t a r t Ti m e = 1 ;
f i r s t L aye r. i n Po i n t = 2 ;
39
JavaScript Reference
40
Attributes
Attribute
Reference
Description
s o u rce
i s Na m e Fro m S o u rce
h eig h t
w i dt h
a ud io E n ab l ed
mo tionBlu r
e f fe c t sAc t ive
adju st mentLayer
g u id e L ayer
t hree DL ayer
co l l ap s e Tr an s fo r m at i on
AVLayer collapseTransformation
attribute on page 43
f r a m e Bl e n di n g
c a n S e t Ti m e Rem a p E n a bl e d
AVLayer canSetTimeRemapEnabled
attribute on page 43
t i m e Rem a p E n a bl e d .
t i m eRem ap E n ab l e d
h as Au di o
a ud io Ac t ive
b l endi ngMo de
AVLayer preserveTransparency
attribute on page 45
t r ackMat teTy p e
i s Tr a ck Ma tte
h as Tr a ck Ma tte
qu a l i t y
40
JavaScript Reference
41
Method
Method
Reference
Description
a udio Ac t iveAtTime()
Boolean; read/write.
Boolean; read-only.
Returns true if this layer's audio will be active at the specified time.
For this method to return true, a ud io E n ab l ed must be true, no other layer with audio may be soloing unless
this layer is soloed too, and the time must be between the i n Poin t and outPoint of this layer.
Parameters
time
Returns
Boolean.
41
JavaScript Reference
42
When true, the layer's audio is enabled. This value corresponds to the audo toggle switch in the Timeline
panel.
Type
Boolean; read/write.
42
JavaScript Reference
43
Bl e n d in g Mod e .OV E R L AY
Bl e n d in g Mod e .PI N _ L I G H T
Bl e n d in g Mod e .S AT U RAT I O N
Bl e n d in g Mod e .S C R E E N
Bl e n d in g Mod e .S I L H OU E T E _ AL PH A
Bl e n d in g Mod e .S I L H OU E T T E _ LUM A
Bl e n d in g Mod e .S O F T _ L I G HT
Bl e n d in g Mod e .S T E N C I L _ A L PHA
Bl e n d in g Mod e .S T E N C I L _ LUM A
B l e n d in g Mod e . V I V I D _ L I G H T
True if it is legal to change the value of the co l l a ps eTr an sfor m at i on attribute on this layer.
Type
Boolean; read-only.
True if it is legal to change the value of the t i m eRem ap E n ab l e d attribute on this layer.
Type
Boolean; read-only.
Boolean; read/write.
True if the layer's effects are active, as indicated by the <f> icon next to it in the user interface.
Type
Boolean; read/write.
43
JavaScript Reference
44
Boolean; read/write.
Boolean; read/write.
True if the layer contains an audio component, regardless of whether it is audio-enabled or soloed.
Type
Boolean; read-only.
True if the layer in front of this layer is being used as a track matte on this layer. When true, this layer's t r a ck Ma tteTy p e value controls how the matte is applied.
Type
Boolean; read-only.
Floating-point; read-only.
44
JavaScript Reference
45
True if the layer has no expressly set name, but contains a named source. In this case, laye r. n am e has the same
value as l ay e r.s ource .nam e .
False if the layer has an expressly set name, or if the layer does not have a source.
Type
Boolean; read-only.
True if this layer is being used as a track matte for the layer behind it.
Type
Boolean; read-only.
Boolean; read/write.
Boolean; read/write.
45
JavaScript Reference
46
Type
The source AVItem for this layer. The value is null in a Text layer.
Type
Boolean; read/write.
Boolean; read/write.
If this layer has a track matte, specifies the way the track matte is applied.
46
JavaScript Reference
47
Type
Floating-point; read-only.
47
JavaScript Reference
48
CameraLayer object
a pp. pro je c t .i tem ( in d e x) .l ayer(i n de x )
Description
The CameraLayer object represents a camera layers within a composition. Create it using the LayerCollection
objects a d dC am er a method; see LayerCollection addCamera() method on page 91. It can be accessed in an
items layer collection either by index number or by a name string.
CameraLayer is a subclass of Layer. All methods and attributes of Layer are available when working with
CameraLayer defines no additional attributes, but has different AE properties than other layer types. It has the
following properties and property groups:
Ma r ker
Tr an s for m
Poi n t of In teres t
Pos i t i on
S c al e
Orientation
X Rot at i on
Y Rot at i o n
Rot at i o n
O p a ci t y
C a m e r a O p t i on s
Zoom
D ep th of F i e ld
Foc u s D i st an ce
Blu r Le ve l
48
JavaScript Reference
49
Collection object
Like an array, a collection associates a set of objects or values as a logical group and provides access to them
by index. However, most collection objects are read-only. You do not assign objects to them yourselftheir
contents update automatically as objects are created or deleted.
The index numbering of a collection starts with 1, not 0.
Objects
Object
Reference
Description
ItemCol l ec t i on
ItemCollection object on page 77 All of the items (imported files, folders, solids, and so on) found in
the Project panel.
L ayer Co l l e c t i on
LayerCollection object on
page 90
O MCol l ec t i on
RenderQueueItem object on
page 150
Attributes
length
Methods
[]
Retrieves an object in the collection by its index number. The first object is at index 1.
49
JavaScript Reference
50
CompItem object
a pp. pro je c t .i tem ( i n d e x)
a pp. pro je c t .i tem s [ inde x ]
Description
The CompItem object represents a composition, and allows you to manipulate and get information about it.
Access the objects by position index number in a projects i te m collection.
CompItem is a subclass of AVItem, which is a subclass of Item. All methods and attributes of AVItem and
Item, in addition to those listed below, are available when working with CompItem. See AVItem object on
page 32 and Item object on page 74.
Example
Given that the first item in the project is a CompItem, the following code displays two alerts. The first shows
the number of layers in the CompItem, and the second shows the name of the last layer in the CompItem.
v ar f i r s t Co m p = a p p. p ro je c t .i te m ( 1 ) ;
a l er t ( " nu m b e r o f l ayer s i s " + f i r s t Co m p.num L aye r s ) ;
a l er t ( " n a m e o f l a s t l ayer i s " + f i r s t Co m p. l ayer ( f i r s t Com p.n u m L ayers ) . n a m e ) ;
Attributes
Attribute
Reference
f r a m eD ur a t i on
wor k Area St ar t
wor k Area D ur a ti on
CompItem workAreaDuration
attribute on page 56
nu m L ayers
h id eS hy L ayers
CompItem hideShyLayers attribute on When true, shy layers are visible in the Timeline panel.
page 53
mo tionBlu r
d r a ft 3 d
f r a m e Bl e n di n g
CompItem frameBlending attribute on When true, time filtering is enabled for this composipage 52
tion.
CompItem preserveNestedFrameRate
attribute on page 54
attribute on page 55
Description
b g Co lor
a c t iveC am er a
d i sp l ay S ta r t Ti m e
50
JavaScript Reference
51
Attribute
Reference
Description
res o lut i o n Fa c to r
The factor by which the x and y resolution of the Composition panel is downsampled.
s hu t ter A n g l e
s hu t ter P h a se
l ayer s
s e l e c te d L ayer s
s e l e c t e d Pro p e r t i e s
CompItem selectedProperties
attribute on page 56
renderer
renderers
Methods
Method
Reference
Description
du pl i c ate( )
l ayer ()
The active camera, which is the front-most camera layer that is enabled. The value is null if the composition
contains no enabled camera layers.
Type
The background color of the composition. The three array values specify the red, green, and blue components
of the color.
Type
An array containing three floating-point values, [R, G, B], in the range [0.0..1.0]; read/write.
51
JavaScript Reference
52
The time set as the beginning of the composition, in seconds. This is the equivalent of the Start Timecode or
Start Frame setting in the Composition Settings dialog box.
Type
Floating-point value in the range [0.0...86339.0] (1 second less than 25 hours); read/write.
When true, Draft 3D mode is enabled for the Composition panel. This corresponds to the value of the Draft
3D button in the Composition panel.
Type
Boolean; read/write.
Creates and returns a duplicate of this composition, which contains the same layers as the original.
Parameters
None.
Returns
CompItem object.
When true, frame blending is enabled for this Composition. Corresponds to the value of the Frame Blending
button in the Composition panel.
Type
52
JavaScript Reference
53
The duration of a frame, in seconds. This is the inverse of the f r am e R a te value (frames-per-second).
Type
Floating-point; read/write.
When true, only layers with s hy set to false are shown in the Timeline panel. When false, all layers are visible,
including those whose shy value is true. Corresponds to the value of the Hide All Shy Layers button in the
Composition panel.
Type
Boolean; read/write.
Returns a Layer object, which can be specified by name, an index position in this layer, or an index position
relative to another layer.
Parameters
i n dex
The index number of the desired layer in this composition. An integer in the range [1...numLayers], where n u m Laye r s is the number of layers in the composition.
or
otherL ayer
A Layer object in this composition. The re lIn d ex value is added to the index value of this
layer to find the position of the desired layer.
rel In dex
The position of the desired layer, relative to o ther L ayer . An integer in the range [1oth erL ayer. in d ex . . . numLayerso ther L ayer.index ], where n u m Laye r s is the number of
layers in the composition.
This value is added to the otherL ayer value to derive the absolute index of the layer to
return.
or
name
53
JavaScript Reference
54
Returns
Layer object.
A LayerCollection object that contains all the Layer objects for layers in this composition. See LayerCollection
object on page 90.
Type
When true, motion blur is enabled for the composition. Corresponds to the value of the Motion Blur button
in the Composition panel.
Type
Boolean; read/write.
Integer; read-only.
When true, the frame rate of nested compositions is preserved in the current composition. Corresponds to the
value of the Preserve frame rate when nested or in render queue option in the Advanced tab of the Composition Settings dialog box.
Type
Boolean; read/write.
54
JavaScript Reference
55
When true, the resolution of nested compositions is preserved in the current composition. Corresponds to the
value of the Preserve resolution when nested option in the Advanced tab of the Composition Settings dialog
box.
Type
Boolean; read/write.
The current rendering plugin module to be used to render this composition, as set in the Advanced tab of the
Composition > Composition Settings dialog box. Allowed values are the members of c o m p It e m . ren d erers .
Type
String; read/write.
The available rendering plugin modules. Member strings reflect installed modules, as seen in the Advanced
tab of the Composition > Composition Settings dialog box.
Type
55
JavaScript Reference
56
All of the selected layers in this composition. This is a 0-based array (the first object is at index 0).
Type
All of the selected properties (Property and PropertyGroup objects) in this composition. The first property is
at index position 0.
Type
The shutter angle setting for the composition. This corresponds to the Shutter Angle setting in the Advanced
tab of the Composition Settings dialog box.
Type
The shutter phase setting for the composition. This corresponds to the Shutter Phase setting in the Advanced
tab of the Composition Settings dialog box.
Type
The duration of the work area in seconds. This is the difference of the start-point and end-point times of the
Composition work area.
56
JavaScript Reference
57
Type
Floating-point; read/write.
Floating-point; read/write.
57
JavaScript Reference
58
FileSource object
a pp. pro je c t .i tem ( in d e x) . m a i n S o u rce
a pp. pro je c t .i tem ( in d e x) .p roxySo urce
Description
listed below, are available when working with FileSource. See FootageSource object on page 65.
Attributes
Attribute
Reference
Description
f i le
m i s s i n g Fo ot a g e Pat h
FileSource missingFootagePath attribute The file that contains footage missing from this asset.
on page 58
Methods
Method
Reference
Description
rel o a d ()
The ExtendScript File object for the file that defines this asset. To change the value:
If this FileSource is a prox y S ource of an AVItem, call s e t Prox y ( ) or se tProx y Wi th S equ ence( ) .
If this FileSource is a m a i n S o u rce of a FootageItem, call rep l ace( ) or repla ceWith S equence() .
Type
The path and filename of footage that is missing from this asset. See also AVItem footageMissing attribute
on page 33.
Type
String; read-only.
58
JavaScript Reference
59
Reloads the asset from the file. This method can be called only on a m a i n S o u rce , not a p roxy S o u rce .
Parameters
None.
Returns
Nothing.
59
JavaScript Reference
60
FolderItem object
a pp. pro je c t .FolderItem
Description
The FolderItem object corresponds to a folder in your Project panel. It can contain various types of items
(footage, compositions, solids) as well as other folders.
Example
Given that the second item in the project is a FolderItem, the following code puts up an alert for each top-level
item in the folder, showing that items name.
v ar secondItem = app.proj ec t. item(2 );
if ( !(secondItem inst anceof Fo lderItem) ) {
a l er t( "problem: se cond item is no t a folder");
} else {
for ( i = 1 ; i <= s econd Item.nu m Item s; i + + ) {
a l er t ( " i tem nu m b e r " + i + " w i t h i n t h e f o l d e r i s n a m e d "
+ se cond Item .item( i) .n ame) ;
}
}
Attributes
Attribute
Reference
Description
i te m s
nu m Item s
Method
Reference
Description
i te m ( )
Methods
Returns the top-level item in this folder at the specified index position. Note that top-level here means toplevel within the folder, not necessarily within the project.
Parameters
i n dex
An integer, the position index of the item to retrieve. The first item is at index 1.
Returns
Item object.
60
JavaScript Reference
61
An ItemCollection object containing Item object that represent the top-level contents of this folder.
Unlike the ItemCollection in the Project object, this collection contains only the top-level items in the folder.
Top-level within the folder is not the same as top-level within the project. Only those items that are top-level
in the root folder are also top-level in the Project.
Type
The number of items contained in the i te m s collection (fold e r Ite m .item s. l en gth ).
If the folder contains another folder, only the FolderItem for that folder is counted, not any subitems
contained in it.
Type
61
JavaScript Reference
62
FootageItem object
a pp. pro je c t .i tem ( i n d e x)
a pp. pro je c t .i tem s [ inde x ]
Description
The FootageItem object represents a footage item imported into a project, which appears in the Project panel.
These are accessed by position index number in a projects i tem collection.
FootageItem is a subclass of AVItem, which is a subclass of Item. All methods and attributes of AVItem and
Item, in addition to those listed below, are available when working with FootageItem. See AVItem object
on page 32 and Item object on page 74.
Attributes
Attribute
Reference
Description
f i le
m a i n S o u rce
Methods
Method
Reference
Description
rep l ace( )
FootageItem replaceWithSequence()
method on page 64
rep l a ce Wi t h S o l i d ()
FootageItem replaceWithSolid()
method on page 64
62
JavaScript Reference
63
The footage source, an object that contains all of the settings related to that footage item, including those that
are normally accessed through the Interpret Footage dialog box. The attribute is read-only. To change its value,
call one of the FootageItem replace methods.
See the FootageSource object on page 65, and its three types:
SolidSource object on page 162
FileSource object on page 58
PlaceholderSource object on page 103
If this is a FileSource object, and the f o o t a g e M i s s i n g value is true, the path to the missing footage file is in the
F i l e S o u rce.m is s in g Fo o t ag e Pa th attribute. See AVItem footageMissing attribute on page 33 and FileSource
Changes the source of this FootageItem to the specified file. In addition to loading the file, the method creates
a new FileSource object for the file and sets m a i n S o u rce to that object. In the new source object, it sets the
n a m e , w i d th , heig ht , f r a m eD ur a t i on , and du r at i on attributes (see AVItem object on page 32) based on the
contents of the file.
The method preserves interpretation parameters from the previous m a in S o u rce object. If the specified file has
an unlabeled alpha channeI, the method estimates the alpha interpretation.
Parameters
file
An ExtendScript File object for the file to be used as the footage main source.
Changes the source of this FootageItem to the specified placeholder. Creates a new PlaceholderSource object,
sets its values from the parameters, and sets m a in S o u rce to that object.
Parameters
name
w i dt h
h eig h t
63
JavaScript Reference
64
f r a m eRa te
The frame rate of the placeholder, a floating-point value in the range [1.0..99.0]
du r at i on
The duration of the placeholder in seconds, a floating-point value in the range [0.0..10800.0].
Changes the source of this FootageItem to the specified image sequence. In addition to loading the file, the
method creates a new FileSource object for the file and sets m a i n S o u rce to that object. In the new source
object, it sets the n am e , w id t h , h ei g h t , fr ameD u r at ion , and dur a t i on attributes (see AVItem object on
page 32) based on the contents of the file.
The method preserves interpretation parameters from the previous m a in S o u rce object. If the specified file has
an unlabeled alpha channeI, the method estimates the alpha interpretation.
Parameters
file
An ExtendScript File object for the first file in the sequence to be used as the footage main source.
force Alp ha b e t ic a l
Changes the source of this FootageItem to the specified solid. Creates a new SolidSource object, sets its values
from the parameters, and sets m a i n S o u rce to that object.
Parameters
co lor
The color of the solid, an array of three floating-point values, [R, G, B], in the range [0.0..1.0].
name
w i dt h
h eig h t
p i xel As p e c t
The pixel aspect ratio of the solid, a floating-point value in the range [0.01..100.0].
64
JavaScript Reference
65
FootageSource object
a pp. pro je c t .i tem ( in d e x) .m a i n S o u rce
a pp. pro je c t .i tem ( in d e x) .p roxySo urce
Description
The FootageSource object holds information describing the source of some footage. It is used as the
m a i n S o u rce of a FootageItem, or the prox y S ou rce of a CompItem or FootageItem. See FootageItem object
on page 62 and CompItem object on page 50.
FootageSource is the base class for SolidSource, so FootageSource attributes and methods are available
when working with SolidSource objects. See SolidSource object on page 162.
Attributes
Attribute
Reference
Description
h as Al p ha
a l pha Mod e
premu l Col or
i nver t A l pha
i s St i l l
f i e l d S e p a r a t i on Ty p e
FootageSource fieldSeparationType
attribute on page 67
h ig hQ ua l it y F ie l dS epa r a ti on
FootageSource removePulldown
attribute on page 69
l o op
n a t iveFr a m e R a te
FootageSource nativeFrameRate
attribute on page 69
d i sp l ay Fr am e R ate
FootageSource displayFrameRate
attribute on page 66
con f or m Fr a m e R a te
FootageSource conformFrameRate
attribute on page 66
Methods
Method
Reference
Description
FootageSource guessAlphaMode()
method on page 67
g u e ss Pu l l dow n ()
FootageSource guessPulldown()
method on page 67
65
JavaScript Reference
66
The alphaMode attribute of footageSource defines how the alpha information in the footage is to be interpreted. If hasAlpha is false, this attribute has no relevant meaning.
Type
A frame rate to use instead of the n a t ive Fr a m e R a te value. If set to 0, the n a t iveFr a m e R a te is used instead.
It is an error to set this value if Fo o t a g e S o urce . i s S t i l l is true. It is an error to set this value to 0 if rem ove Pul l dow n is not set to Pu l l dow n P h a se . O F F. If this is 0 when you set rem ovePul ld ow n to a value other than
Pul l dow n Ph a s e . O F F, then this is automatically set to the value of n a t iveFr a m e Ra te .
Type
The effective frame rate as displayed and rendered in compositions by After Effects.
If rem ove Pul l dow n is Pu l l dow n P h a s e . O F F, then this is the same as the con fo r m Fr a m e R ate (if non-zero) or
the n a t iveFr a m e R a te (if con f o r m Fr a m e R ate is 0). If rem ovePu l l dow n is not Pu l l dow n P h a se . O F F, this is
con f o r m Fr a m e R a te * 0.8, the effective frame rate after removing 1 of every 5 frames.
Type
66
JavaScript Reference
67
Sets a lp ha Mode , premu l Col or, and inver tAl ph a to the best estimates for this footage source. If h as Al p ha is
false, no change is made.
Parameters
None.
Returns
Nothing.
Sets f i e l d S e p a r a t i o n Ty p e and rem ove Pul l dow n to the best estimates for this footage source. If i s S t il l is true,
no change is made.
Parameters
method
The method to use for estimation. A Pul l dow n Met ho d enumerated value, one of:
Pul l d ow n Met h o d. PU L L D OW N _ 3 _ 2
Pul l dow n Met ho d. ADVANCE _24P
Returns
Nothing.
67
JavaScript Reference
68
When true, the footage has an alpha component. In this case, the attributes a lp ha Mode , i nver t A lp h a , and
premu l Col or have valid values. When false, those attributes have no relevant meaning for the footage.
Type
Boolean; read-only.
When true, After Effects uses special algorithms to determine how to perform high-quality field separation.
It is an error to set this attribute if i sS t i l l is true, or if f i e l d S e p a r a t i o n Ty p e is F i e l d S e p a r a t i o n Ty p e .O F F.
Type
Boolean; read/write.
Boolean; read/write.
When true the footage is still; when false, it has a time-based component.
Examples of still footage are JPEG files, solids, and placeholders with duration of 0. Examples of non-still
footage are movie files, sound files, sequences, and placeholders of non-zero duration.
Type
Boolean; read-only.
68
JavaScript Reference
69
The number of times that the footage is to be played consecutively when used in a composition.
It is an error to set this attribute if i sS t i l l is true.
Type
Floating-point; read/write.
The color to be premultiplied. This attribute is valid only if the a l pha Mod e is a l pha Mo de .P R E M ULT I P L I E D .
Type
69
JavaScript Reference
70
70
JavaScript Reference
71
ImportOptions object
n e w Im p o r t O p t i on s ( ) ;
n e w Im p o r t O p t i on s ( file ) ;
Description
The ImportOptions object encapsulates the options used to import a file with the Proj ec t. i m p or t F il e
methods. See Project importFile() method on page 107.
The constructor takes an optional parameter, an ExtendScript File object for the file. If it is not supplied, you
must explicitly set the value of the f i l e attribute before using the object with the i m p o r tF i l e method. For
example:
n e w Im p o r t O p t i on s ( ) . f i l e = n e w F i l e ( "my f i le . p s d " ) ;
Attributes
Attributes
Reference
Description
i m p o r tAs
s e qu e n ce
force Alp ha b e ti c a l
ImportOptions forceAlphabetical
attribute on page 72
f i le
Methods
Method
Reference
Description
c a n Im p or t As ( )
Reports whether the file can be imported as the source of a particular object type. If this method returns true,
you can set the given type as the value of the i m p o r tAs attribute. See ImportOptions importAs attribute on
page 72.
Parameters
type
Im p o r t AsTy p e . C OM P
Im p o r t AsTy p e . F O OTAG E
Im p o r t AsTy p e . C OM P_ C ROP PE D_ L AY E R S
Im p o r t AsTy p e . PRO J E C T
71
JavaScript Reference
72
Returns
Boolean.
Example
v ar i o = n e w Im p o r t O p ti o n s ( F i l e ( c :\ \ my F i l e . ps d )) ;
i f io. c an Im p or t As ( Im p or tAs Ty p e.C O MP ) ;
i o.i m p o r tAs = Im p o r tAs Ty p e.C O M P;
The file to be imported. If a file is set in the constructor, you can access it through this attribute.
Type
When true, has the same effect as setting the Force alphabetical order option in the File > Import > File
dialog box.
Type
Boolean; read/write.
The type of object for which the imported file is to be the source. Before setting, use can Im p or tAs to check
that a given file can be imported as the source of the given object type. See ImportOptions canImportAs()
method on page 71.
Type
72
JavaScript Reference
73
Boolean; read/write.
73
JavaScript Reference
74
Item object
a pp. pro je c t .i tem ( i n dex )
a pp. pro je c t .i te m s [ in d ex ]
Description
The Item object represents an item that can appear in the Project panel.
The first item is at index 1.
Item is the base class for AVItem and for FolderItem, which are in turn the base classes for various other
item types, so Item attributes and methods are available when working with all of these item types. See
AVItem object on page 32 and FolderItem object on page 60.
Attributes
Attributes
Reference
Description
name
com m e n t
A descriptive string.
id
p aren tFol de r
s e l e c te d
t y p e Na m e
Method
Reference
Description
rem ove( )
Methods
Example
This example gets the second item from the project and checks that it is a folder. It then removes from the
folder any top-level item that is not currently selected. It also checks to make sure that, for each item in the
folder, the parent is properly set to the correct folder.
v ar my Folder = a pp.proje c t.item (2);
i f (my Fo ld e r. t y p e Nam e ! = " Fo l d e r " ) {
a l er t( " e r ro r : s e con d i te m i s n o t a fo ld e r " );
}
e l se {
v ar nu mInFolder = my Fo lder.numItems;
/ / A lw ay s r u n l o o p s b a ck wa rds w h en del e t i n g th i n g s:
f o r ( i = n u m In Fo l d e r ; i > = 1 ; i- - ) {
v ar c ur Item = my Fol d er. item (i ) ;
i f ( c ur Item .p aren tFol der != myFol der ) {
a l er t( " er ro r w i thi n A E : t he p aren t Fol d er is n o t s et cor re c t ly " ) ;
}
e l se {
i f ( ! c u rIte m . s e l e c t e d & & c u r Item . t y p eNam e = = " Fo ot a g e " ) {
/ / A h a ! an u n s e l e c te d so li d .
c u r Item . rem ove ( ) ;
74
JavaScript Reference
75
}
}
}
}
A string that holds a comment, up to 15,999 bytes in length after any encoding conversion. The comment is
for the user's purpose only; it has no effect on the item's appearance or behavior.
Type
String; read/write.
Item id attribute
a pp. pro je c t .i tem ( in d e x) .i d
Description
A unique and persistent identification number used internally to identify an item between sessions. The value
of the ID remains the same when the project is saved to a file and later reloaded. However, when you import
this project into another project, new IDs are assigned to all items in the imported project. The ID is not
displayed anywhere in the user interface.
Type
Integer; read-only.
String; read/write.
The FolderItem object for the folder that contains this item. If this item is at the top level of the project, this
is the project's root folder (a p p.p ro je c t .ro o t Fol d e r ). You can use the ItemCollections ad d Fo l d e r method to
add a new folder, and set this value to put items in the new folder. See ItemCollection addFolder() method
on page 77.
75
JavaScript Reference
76
Type
This script creates a new FolderItem in the Project panel and moves compositions into it.
/ / c re a t e a n e w Fol d e r Ite m i n p ro j e c t , w i t h n a m e co m p s
v ar compFolder = app.proj ec t. items. a ddFo l der(com ps );
/ / m ove a l l com p o s i t i o n s i n t o n e w f o l d e r by s e t t in g
/ / com p Ite ms p a ren t Fol d e r to com p s f o l d e r
for ( v a r i = 1 ; i <= a p p.p ro j e c t . num Item s ; i + +) {
i f (a pp. pro j e c t . i tem ( i ) i n s ta n ce o f C om pIte m )
a pp. pro je c t .i tem( i ). pa rent Fol der = compFol d er ;
}
Deletes this item from the project and from the Project panel. If the item is a FolderItem, all the items
contained in the folder are also removed from the project. No files or folders are removed from disk.
Parameters
None.
Returns
Nothing.
When true, this item is selected. Multiple items can be selected at the same time. Set to true to select the item
programmatically, or to false to deselect it.
Type
Boolean; read/write.
A user-readable name for the item type; for example, Folder, Footage, or Composition.
Type
String; read-only.
76
JavaScript Reference
77
ItemCollection object
a pp. pro je c t .i tem s
Description
The ItemCollection object represents a collection of items. The ItemCollection belonging to a Project object
contains all the Item objects for items in the project. The ItemCollection belonging to a FolderItem object
contains all the Item objects for items in that folder.
ItemCollection is a subclass of Collection. All methods and attributes of Collection, in addition to those
listed below, are available when working with ItemCollection. See Collection object on page 49.
Methods
Method
Reference
Description
a d dCom p ( )
a d dFol der( )
Creates a new composition. Creates and returns a new CompItem object and adds it to this collection.
If the ItemCollection belongs to the project or the root folder, then the new items p aren tFol de r is the root
folder. If the ItemCollection belongs to any other folder, the new items pa ren tFol der is that Fol d erItem .
Parameters
name
w i dt h
h eig h t
p i xel As p e c t
The pixel aspect ratio of the composition, a floating-point value in the range [0.01..100.0].
du r at i on
The duration of the composition in seconds, a floating-point value in the range [0.0..10800.0].
f r a m eRa te
The frame rate of the composition, a floating-point value in the range [1.0..99.0]
Returns
CompItem object.
Creates a new folder. Creates and returns a new FolderItem object and adds it to this collection.
77
JavaScript Reference
78
If the ItemCollection belongs to the project or the root folder, then the new folders pa ren tFol der is the root
folder. If the ItemCollection belongs to any other folder, the new folders p a ren t Fol d e r is that FolderItem .
To put items in the folder, set the item objects p aren tFol de r attribute; see Item parentFolder attribute on
page 75.
Parameters
name
Returns
FolderItem object.
Example
This script creates a new FolderItem in the Project panel and moves compositions into it.
/ / c re a t e a n e w Fol d e r Ite m i n p ro j e c t , w i t h n a m e co m p s
v ar compFolder = app.proj ec t. items. a ddFo l der(com ps );
/ / m ove a l l com p o s i t i o n s i n t o n e w f o l d e r by s e t t in g
/ / com p Ite ms p a ren t Fol d e r to com p s f o l d e r
for ( v a r i = 1 ; i <= a p p.p ro j e c t . num Item s ; i + +) {
i f (a pp. pro j e c t . i tem ( i ) i n s ta n ce o f C om pIte m )
a pp. pro je c t .i tem( i ). pa rent Fol der = compFol d er ;
}
78
JavaScript Reference
79
KeyframeEase object
my Ke y = n ew Ke y f r am e E as e( s p e e d, i n f l u e n c e );
Description
The KeyframeEase object encapsulates the keyframe ease settings of a layers AE property. There are two types
of ease, temporal and spatial, which are determined by the speed and influence settings. Both types are set
using the propertys s e t Te m p o r al E as e AtKe y method. See Property setTemporalEaseAtKey() method on
page 131.
The constructor creates a KeyframeEase object. Both parameters are required.
s p e e d : A floating-point value. Sets the sp ee d attribute.
i n f lu en ce : A floating-point value in the range [0.1..100.0]. Sets the in f lu en ce attribute.
Example
This example assumes that the Position, a spatial property, has more than two keyframes.
v ar e a s e In = n e w Ke y fr am e E as e ( 0 .5 , 5 0 ) ;
v ar e a s e Out = n e w Ke y fr am e E as e ( 0 .7 5 , 8 5 ) ;
v ar my Pos i t i o n Pro p e r t y = a p p. p ro je c t . i te m ( 1) .l ayer (1 ).p rop er t y (" Po si t i on " )
my Pos i t i o n Pro p e r t y. se tTem p o r a l E as e At Ke y ( 2 , [ e a se In ], [ e a se Ou t ] ) ;
This example sets the Scale, a temporal property with two dimensions. For 2D and 3D properties you must
set an e as eIn and and easeO ut value for each dimension:
v ar e a s e In = n e w Ke y fr am e E as e ( 0 .5 , 5 0 ) ;
v ar e a s e Out = n e w Ke y fr am e E as e ( 0 .7 5 , 8 5 ) ;
v ar my S c a l e Prop e r t y = a p p. p ro je c t .i te m ( 1 ) . l ayer (1 ) . p rop e r t y ( " S c a l e " )
my Sca l eProp er t y.se tTempor alEa s eAt Ke y (2, [ea se In, ea seIn , easeIn ], [ea seO ut, ea seO ut , ea se Out ]);
Attributes
Attribute
Reference
Description
speed
i n f lu e n ce
The influence value of the keyframe, as shown in the Keyframe Velocity dialog box.
Type
79
JavaScript Reference
80
The speed value of the keyframe. The units depend on the type of keyframe, and are displayed in the Keyframe
Velocity dialog box.
Type
80
JavaScript Reference
81
Layer object
a pp. pro je c t .i tem ( in d e x) .l ayer(i n de x )
Description
The Layer object provides access to layers within compositions. It can be accessed from an items layer
collection either by index number or by a name string.
Layer is the base class for CameraLayer, TextLayer, LightLayer, and AVLayer, so Layer attributes and
methods are available when working with all layer types. See AVLayer object on page 39,
CameraLayer object on page 48, LightLayer object on page 94, and TextLayer object on page 166.
Layers contain AE properties, in addition to their JavaScript attributes and methods. For examples of how to
access properties in layers, see PropertyBase object on page 135.
Example
If the first item in the project is a CompItem, this example disables the first layer in that composition and
renames it. This might, for example, turn an icon off in the composition.
v ar f i r s t L aye r = a p p. p ro je c t .i te m ( 1 ) . l ayer (1 ) ;
f i r st L aye r.en a bl e d = f al s e ;
first L ayer.na m e = "D isa ble d Layer";
Attributes
Attribute
Reference
Description
i n dex
name
p aren t
time
s ta r t Ti m e
s t retch
i n Poi n t
o u t Po i n t
e n a bl e d
solo
s hy
l o cke d
h as Vi de o
a c t ive
nu l l L aye r
s e l e c t e d Pro p e r t i e s
com m e n t
con t a i n i n g Com p
81
JavaScript Reference
82
Attribute
Reference
Description
i s Na m e S e t
Methods
Method
Reference
Description
rem ove( )
m oveToB e g i n n i n g ( )
m oveToE n d ( )
moveAfter()
Layer moveAfter() method on page 85 Moves the layer below another layer.
m oveB e f ore( )
du pl i c ate( )
copy ToCom p ( )
a c t iveAtTim e()
s e tPare n t Wi th Ju m p ( )
a pp ly Pre se ts ( )
Boolean; read-only.
Returns true if this layer will be active at the specified time. To return true, the layer must be enabled, no other
layer may be soloing unless this layer is soloed too, and the time must be between the in Poi n t and o utPoi n t
values of this layer.
82
JavaScript Reference
83
Parameters
time
Returns
Boolean.
Applies the specified collection of animation settings (an animation preset) to the layer. Predefined animation
preset files are installed in the Presets folder, and users can create new animation presets through the user
interface.
Parameters
pres e tNam e
An ExtendScript File object for the file containing the animation preset.
Returns
Nothing.
String; read/write.
83
JavaScript Reference
84
Copies the layer into the specified composition. The original layer remains unchanged. Creates a new Layer
object with the same values as this one, and prepends the new object to the l ayer s collection in the target
CompItem. Retrieve the copy using i n t o Com p.layer( 1) .
Copying in a layer changes the index positions of previously existing layers in the target composition. This is
the same as copying and pasting a layer through the user interface.
Parameters
i n toC om p
Returns
Nothing.
Duplicates the layer. Creates a new Layer object in which all values are the same as in this one. This has the
same effect as selecting a layer in the user interface and choosing Edit > Duplicate, except the selection in the
user interface does not change when you call this method.
Parameters
None.
Returns
Layer object.
When true, the layer is enabled; otherwise false. This corresponds to the video switch state of the layer in the
Timeline panel.
Type
Boolean; read/write.
When true, the layer has a video switch (the eyeball icon) in the Timeline panel; otherwise false.
84
JavaScript Reference
85
Type
Boolean; read-only.
Floating-point value in the range [-10800.0..10800.0] (minus or plus three hours); read/write.
True if the value of the n a m e attribute has been set explicitly, rather than automatically from the source.
Type
Boolean; read-only.
When true, the layer is locked; otherwise false. This correponds to the lock toggle in the Layer panel.
Type
Boolean; read/write.
Moves this layer to a position immediately after (below) the specified layer.
85
JavaScript Reference
86
Parameters
l ayer
Returns
Nothing.
Moves this layer to a position immediately before (above) the specified layer.
Parameters
l ayer
Returns
Nothing.
Moves this layer to the topmost position of the layer stack (the first layer).
Parameters
None.
Returns
Nothing.
Moves this layer to the bottom position of the layer stack (the last layer).
Parameters
None.
Returns
Nothing.
86
JavaScript Reference
87
The name of the layer. By default, this is the same as the Source name (which cannot be changed in the Layer
panel), but you can set it to be different.
Type
String; read/write.
When true, the layer was created as a null object; otherwise false.
Type
Boolean; read-only.
Floating-point value in the range [-10800.0..10800.0] (minus or plus three hours); read/write.
87
JavaScript Reference
88
None.
Returns
Nothing.
An array containing all of the currently selected Property and PropertyGroup objects in the layer.
Type
Sets the parent of this layer to the specified layer, without changing the transform values of the child layer.
There may be an apparent jump in the rotation, translation, or scale of the child layer, as this layers transform
values are combined with those of its ancestors.
If you do not want the child layer to jump, set the p aren t attribute directly. In this case, an offset is calculated
and set in the child layer's transform fields, to prevent the jump from occurring.
Parameters
n e w Pa re n t
Returns
Nothing.
When true, the layer is shy, meaning that it is hidden in the Layer panel if the compositions Hide all shy
layers option is toggled on.
88
JavaScript Reference
89
Type
Boolean; read/write.
Boolean; read/write.
Floating-point value in the range [-10800.0..10800.0] (minus or plus three hours); read/write.
The layers time stretch, expressed as a percentage. A value of 100 means no stretch. Values between 0 and 1
are set to 1, and values between -1 and 0 (not including 0) are set to -1.
Type
89
JavaScript Reference
90
LayerCollection object
a pp. pro je c t .i tem ( i n d e x) .l ayers
Description
The LayerCollection object represents a set of layers. The LayerCollection belonging to a CompItem object
contains all the layer objects for layers in the composition. The methods of the collection object allow you to
manipulate the layer list.
LayerCollection is a subclass of Collection. All methods and attributes of Collection, in addition to those
listed below, are available when working with LayerCollection. See Collection object on page 49.
Example
Given that the first item in the project is a CompItem and the second item is an AVItem, this example shows
the number of layers in the CompItem's layer collection, adds a new layer based on an AVItem in the project,
then displays the new number of layers.
v ar f i r s t Co m p = a p p. p ro je c t .i te m ( 1 ) ;
v ar l ayer Co l l e c t ion = fi r s t Co m p.l ayer s;
a l er t ( " nu m b e r o f l ayer s b efore i s " + l ayer Co l l e c t i o n . l e n g t h ) ;
v ar a n AVItem = a pp.proje c t.i tem (2 );
l ayer Co l l e c t ion . a d d (a n AVIte m ) ;
a l er t ( " nu m b e r o f l ayer s a f ter i s " + l ayer C o l l e c t i o n . l e n g t h ) ;
Methods
Method
Reference
Description
a d d( )
a d dNul l ( )
a d dS o li d ( )
LayerCollection addSolid() method on Creates a new layer, a FootageItem with a SolidSource, and adds it
page 92
to this collection.
a d dTex t( )
a d dCamer a( )
a d dL i g ht ()
LayerCollection addLight() method on Creates a new light layer and adds it to this collection.
page 91
by Na m e( )
pre co m p o s e ( )
LayerCollection precompose()
method on page 93
90
JavaScript Reference
91
Creates a new AVLayer object containing the specified item, and adds it to this collection.
This method generates an exception if the item cannot be added as a layer to this CompItem.
Parameters
i te m
du r at i on
Optional, the length of a still layer in seconds, a floating-point value. Used only if the item contains a piece of
still footage. Has no effect on movies, sequences or audio.
If supplied, sets the du r a ti on value of the new layer. Otherwise, the d u r a t io n value is set according to user
preferences. By default, this is the same as the duration of the containing CompItem. To set another preferred
value, choose Edit > Preferences > Import (Windows) or After Effects > Preferences > Import (Mac OS), and specify options under Still Footage.
Returns
AVLayer object.
Creates a new camera layer and adds the CameraLayer object to this collection.
Parameters
name
cen terPoi n t
The center of the new camera, a floating-point array [x, y]. This is used to set the initial x and y values of the
new cameras Point of Interest property. The z value is set to 0.
Returns
CameraLayer object.
Creates a new light layer and adds the LightLayer object to this collection.
Parameters
name
cen terPoi n t
91
JavaScript Reference
92
Returns
LightLayer object.
Creates a new null layer and adds the AVLayer object to this collection. Ths is the same as choosing
Layer > New > Null Object.
Parameters
du r at i on
Returns
AVLayer object.
Creates a new SolidSource object, with values set as specified; sets the new SolidSource as the m a i n S o u rce
value of a new FootageItem object, and adds the FootageItem to the project. Creates a new AVLayer object,
sets the new FootageItem as its s o u rce , and adds the layer to this collection.
Parameters
co lor
The color of the solid, an array of four floating-point values, [R, G, B, A], in the range [0.0..1.0].
name
w i dt h
h eig h t
p i xel As p e c t
The pixel aspect ratio of the solid, a floating-point value in the range [0.01..100.0].
du r at i on
Returns
AVLayer object.
92
JavaScript Reference
93
Creates a new text layer and adds the new TextLayer object to this collection.
Parameters
s o u rce Tex t
Optional; a string containing the source text of the new layer, or a TextDocument object containing the source text of the new layer. See TextDocument object on page 165.
Returns
TextLayer object.
Returns the first (topmost) layer found in this collection with the specified name, or null if no layer with the
given name is found.
Parameters
name
Returns
Creates a new CompItem object and moves the specified layers into its layer collection. It removes the
individual layers from this collection, and adds the new CompItem to this collection.
Parameters
l ayer In di ce s
name
m oveAl l At t r i bute s
Optional. When true (the default), retains all attributes in the new composition.
This is the same as selecting the Move all attributes into the new composition
option in the Pre-compose dialog box.
You can only set this to false if there is just one index in the l ayer In d i ce s array.
This is the same as selecting the Leave all attributes in option in the Pre-compose dialog box.
Returns
CompItem object.
93
JavaScript Reference
94
LightLayer object
a pp. pro je c t .i tem ( in d e x) .l ayer(i n de x )
Description
The LightLayer object represents a light layer within a composition. Create it using the LayerCollection
objects ad d L ig h t method; see LayerCollection addLight() method on page 91. It can be accessed in an
items layer collection either by index number or by a name string.
LightLayer is a subclass of Layer. All methods and attributes of Layer are available when working with Light-
LightLayer defines no additional attributes, but has different AE properties than other layer types. It has the
following properties and property groups:
Ma r ker
Tr an s for m
Poi n t of In teres t
Pos i t i on
S c al e
Orientation
X Rot at i on
Y Rot at i o n
Rot at i o n
O p a ci t y
L i g ht O p t i o n s
In ten s i t y
Col or
Con e An g l e
Con e Fea th er
C as ts S h a dow s
S h a dow D a r k n e s s
S h a dow D i ff u s i on
94
JavaScript Reference
95
MarkerValue object
new Ma r kerVa lue( c om m e n t , c h ap te r, u r l, f ra m eTar ge t )
Description
The MarkerValue object represents of a layer marker, which associates a comment, and optionally a chapter
and Web-page link with a particular point in a layer. Create it with the constructor; all arguments are strings,
and all except com m e n t are optional. The values are set in the corresponding attributes of the returned
MarkerValue object.
To associate a marker with a layer, set the MarkerValue object in the Mar ker AE property of the layer:
laye rO bj ec t . prop e r t y (" Mar ker " ) .s e tVa lu e AtTi m e (t im e, m a r ke r Val u eO b j e ct );
For information on the usage of markers see Using markers in After Effects Help.
Attributes
Attribute
Reference
Description
com m e n t
cha p ter
ur l
f r a m eTa rg et
Examples
A text chapter link for this marker. Chapter links initiate a jump to a chapter in a QuickTime movie or in other
formats that support chapter marks.
Type
String; read/write.
95
JavaScript Reference
96
A text comment for this marker. This comment appears in the Timeline panel next to the layer marker.
Type
String; read/write.
A text frame target for this marker. Together with the URL value, this targets a specific frame within a Web
page.
Type
String; read/write.
A URL for this marker. This URL is an automatic link to a Web page.
Type
String; read/write.
96
JavaScript Reference
97
MaskPropertyGroup object
a pp. pro je c t .i tem ( i n d e x) .l ayer (i n de x ). mas k
Description
PropertyGroup, in addition to those listed below, are available when working with MaskPropertyGroup.
See PropertyBase object on page 135 and PropertyGroup object on page 142.
Attributes
Attribute
Reference
Description
ma sk Mo de
i nver te d
rotoB ez i er
m a s k Mot i o n B lu r
MaskPropertyGroup maskMotionBlur
attribute on page 98
l o cke d
co lor
The color used to draw the mask outline as it appears in the user interface (Composition panel, Layer panel,
and Timeline panel).
Type
Array of three floating-point values, [R, G, B], in the range [0.0..1.0]; read/write.
Boolean; read/write.
97
JavaScript Reference
98
When true, the mask is locked and cannot be edited in the user interface; otherwise, false.
Type
Boolean; read/write.
Boolean; read/write.
98
JavaScript Reference
99
OMCollection object
a pp. pro je c t .renderQ ueue. items. out p ut Mo dules
Description
The OMCollection contains all of the output modules in a render queue. The collection provides access to the
OutputModule objects, but does not provide any additional functionality. The first OutputModule object in
the collection is at index position 1. See OutputModule object on page 100
OMCollection is a subclass of Collection. All methods and attributes of Collection are available when
99
JavaScript Reference
100
OutputModule object
a pp. pro je c t .renderQ ueue. item (i n de x ). o u t p ut Mo d u l e s ( inde x )
Description
An OutputModule object of a RenderQueueItem generates a single file or sequence via a render operation,
and contains attributes and methods relating to the file to be rendered.
Attributes
Attribute
Reference
Description
f i le
p o s t Ren de r Ac t i o n
OutputModule postRenderAction
attribute on page 101
name
tem pl a tes
Methods
Method
Reference
Description
rem ove( )
OutputModule saveAsTemplate()
method on page 101
a pp ly Te m p l ate ( )
OutputModule applyTemplate()
method on page 100
Returns
Nothing.
The ExtendScript File object for the file this output module is set to render.
100
JavaScript Reference
101
Type
String; read-only.
None.
Returns
Nothing.
Saves this output module as a template and adds it to the templa tes array.
101
JavaScript Reference
102
Parameters
name
Returns
Nothing.
The names of all output-module templates availalbe in the local installation of After Effects.
Type
102
JavaScript Reference
103
PlaceholderSource object
a pp. pro je c t .i tem ( i n d e x) .m a i n S o u rce
a pp. pro je c t .i tem ( i n d e x) .p roxy S o u rce
Description
103
JavaScript Reference
104
Project object
a pp. pro je c t
Description
The project object represents an After Effects project. Attributes provide access to specific objects within the
project, such as imported files or footage and compositions, and also to project settings such as the timecode
base. Methods can import footage, create solids, compositions and folders, and save changes.
Attributes
Attribute
Reference
Description
f i le
rootFo lder
i te m s
a c t iveItem
bitsPerChan n el
t i m e cod eD i sp l ay Ty p e
Project timecodeDisplayType
attribute on page 111
t i m e cod e B as e Ty p e
t i m e cod eN TS C D ro pFr am e
Project timecodeNTSCDropFrame
attribute on page 112
t i m e cod eF i l m Ty p e
nu m Item s
selection
renderQ ueue
d i sp l ay S ta r t Fr a m e
Project displayStartFrame attribute on The frame at which to start numbering when dispage 106
playing the project.
linearBlending
Methods
Method
Reference
Description
i te m ( )
con s ol i d ate Fo ot ag e( )
104
JavaScript Reference
105
Method
Reference
Description
Project removeUnusedFootage()
method on page 109
cl o se( )
s ave( )
s aveWi th Di a l o g ( )
i m p o r tP l ace h o ld e r ( )
Project importFileWithDialog()
method on page 107
i m p o r tF i l e ( )
i m p o r tF i l e Wi t h D i a l o g ()
Project importFileWithDialog()
method on page 107
s h ow Win dow( )
The item that is currently active and is to be acted upon, or a null if no item is currently selected or if multiple
items are selected.
Type
Closes the project with the option of saving changes automatically, prompting the user to save changes or
closing without saving changes.
105
JavaScript Reference
106
Parameters
cl o seO pt i on s
Returns
Boolean. True on success. False if the file has not been previously saved, the user is prompted, and the user
cancels the save.
Consolidates all footage in the project. Same as the File > Consolidate All Footage command.
Parameters
None.
Returns
The frame at which to start numbering when displaying the project with a t i me co deD i sp l ay Ty p e value of
Tim e co de Di s p l ay Ty p e .F R A M E S . (See Project timecodeDisplayType attribute on page 111.) This is the
same as setting Start numbering frames at: in the Project Settings > Display Style tab.
Type
Integer; read/write.
The ExtendScript File object for the file containing the project that is currently open.
Type
106
JavaScript Reference
107
Imports the file specified in the specified ImportOptions object, using the specified options. Same as the
File > Import File command. Creates and returns a new FootageItem object from the file, and adds it to the
projects i te m s array.
Parameters
i m p o r tO p t i o n s
An ImportOptions object specifying the file to import and the options for the operation. See
ImportOptions object on page 71.
Returns
FootageItem object.
Example
a pp. pro je c t .i m p or tF i l e( n ew Im p or tO p t i o n s ( F i l e ( sa m pl e .p sd ) )
Shows an Import File dialog box. Same as the File > Import > File command.
Returns
Array of Item objects created during import; or null if the user cancels the dialog.
Creates and returns a new PlaceholderItem object and adds it to the projects i te m s array. Same as the
File > Import > Placeholder command.
Parameters
name
w i dt h
h eig h t
f r a m eRa te
The frame rate of the placeholder, a floating-point value in the range [1.0..99.0]
du r at i on
The duration of the placeholder in seconds, a floating-point value in the range [0.0..10800.0].
Returns
PlaceholderItem object.
107
JavaScript Reference
108
The index position of the item, an integer. The first item is at index 1.
Returns
Item object.
True if linear blending should be used for this project; othewise false.
Type
Boolean; read/write.
The total number of items contained in the project, including folders and all types of footage.
Type
Integer; read-only.
Example
n = a p p.p ro j e c t . num Item s ;
a l er t ( " T h e re a re " + n + " i te m s i n t h is p ro j e c t . " )
108
JavaScript Reference
109
Removes all items from the project except those specified. Same as the File > Reduce Project command.
Parameters
a r r ay _ of _ i tem s
Returns
Removes unused footage from the project. Same as the File > Remove Unused Footage command.
Parameters
None.
Returns
The root folder containing the contents of the project; this is a virtual folder that contains all items in the
Project panel, but not items contained inside other folders in the Project panel.
109
JavaScript Reference
110
Type
Saves the project. The same as the File > Save or File > SaveAs command. If the project has never previously
been saved and no file is specified, prompts the user for a location and file name. Pass a File object to save a
project to a new file without prompting.
Parameters
file
Returns
None.
Shows the Save dialog box. The user can name a file with a location and save the project, or click Cancel to exit
the dialog.
Parameters
None.
Returns
All items selected in the Project panel, in the sort order shown in the Project panel.
Type
110
JavaScript Reference
111
Parameters
doS h ow
When true, show the Project panel. When false, hide the Project panel.
Returns
Nothing.
The Timecode Base option, as set in the Project Settings dialog box.
Type
The way in which timecode is set to display, as set in the Project Settings dialog box.
Type
The film type, as set in the Feet + Frames option in the Project Settings dialog box.
Type
111
JavaScript Reference
112
How timecode for 29.97 fps footage is displayed, as set in the Project Settings dialog box under NTSC.
Type
Boolean, true for the Drop Frame option, false for the Non-Drop Frame option; read/write.
Boolean; read/write.
112
JavaScript Reference
113
Property object
a pp. pro je c t .i tem ( i n d e x) .l ayer (i n de x ). prop e r t y Sp ec
Description
The Property object contains value, keyframe, and expression information about a particular AE property of
a layer. An AE property is an value, often animatable, of an effect, mask, or transform within an individual
layer. For examples of how to access properties, see PropertyBase object on page 135 and PropertyGroup
property() method on page 144..
PropertyGroup is a subclass of PropertyBase. All methods and attributes of PropertyBase, in addition to
those listed below, are available when working with PropertyGroup. See PropertyBase object on page 135.
NOTE: JavaScript objects commonly referred to as properties are called attributes in this guide, to avoid
confusion with the After Effects definition of property.
Attributes
Attribute
Reference
Description
prop er t y Va lue Ty p e
v alu e
h as Mi n
h as Max
m i n Va lu e
m a x Va lu e
i s Sp a t i a l
i s Ti m e Va r y i n g
nu m Ke y s
un it sTex t
e xp re ss i o n
can S et Ex pression
e xp re ss i o n E n ab l e d
When true, the expression is used to generate values for the property.
e xp re ss i o n E r ror
The error, if any, that occurred when the last expression was evaluated.
113
JavaScript Reference
114
Attribute
Reference
Description
ke y fr am e In ter p ol at i on Ty p e
Property keyframeInterpolationType
attribute on page 119
s e l e c te d Ke y s
prop er t y Index
Methods
Method
Reference
Description
s e tVal u e ( )
s e tVal u e AtTi m e ( )
s e tVal u e s At Ti m e s( )
s e tVal u e AtKe y( )
ne arestKe y In dex()
ke y Ti m e( )
ke y Valu e( )
a d dKe y ()
rem oveKe y ( )
i s In ter p o l a t i o n Ty p e Va l i d ()
Property isInterpolationTypeValid()
method on page 119
s e tIn te r p o l at i o n Ty p e AtKe y( )
Property setInterpolationTypeAtKey()
method on page 128
ke y In In te r p o l at i o n Ty p e ()
Property keyInInterpolationType() method Gets the 'in' interpolation type for a key.
on page 120
ke y Out In ter p ol at i on Ty p e( )
Property keyOutInterpolationType()
method on page 121
s e tS pa t i alTa ngen ts At Ke y( )
Property setSpatialTangentsAtKey()
method on page 130
ke y In Sp at i a lTan g en t ()
ke y Out Sp a ti a l Tan g en t ()
114
JavaScript Reference
115
Method
Reference
Description
ke y In Te m p o r a l E a s e ( )
ke y Out Tem p or a l E as e( )
Property setTemporalContinuousAtKey()
method on page 131
ke y Te m p o r a l Co n t i n u o u s ( )
Property keyTemporalContinuous()
method on page 124
s e t Te m p or al Au to B e z i e r At Ke y( )
Property setTemporalAutoBezierAtKey()
method on page 130
ke y Te m p o r a l Au t o B e z i e r ( )
Property keyTemporalAutoBezier()
method on page 124
s e tS pa t i al Con t i nu o u sAtKe y( )
Property setSpatialContinuousAtKey()
method on page 129
s e tS pa t i al AutoB e z i e r AtKe y
Property setSpatialAutoBezierAtKey()
method on page 129
s e tRov i n g At Ke y ( )
ke y Rov i n g ()
s e tS e l ec te dAtKe y( )
ke y S el e c ted ( )
115
JavaScript Reference
116
my Sh ap e.clo se d = false;
my Prop er t y. s e t Val u e ( myS h a p e );
Example: Get the value of a color at a particular time
A color is stored as an array of four floats, [r,g,b,opacity]. This sets the value of the red component of a light's
color at time 4 to be half of that at time 2:
v ar my Prop er t y = my L i g ht .col or ;
v ar co lor Valu e = my Prop er t y.v alu eAt Ti me (2 ,t r u e) ;
co lor Valu e[0 ] = 0. 5 * col orVa lue[ 0] ;
my Prop er t y.set ValueAtTime(4,co lor Valu e);
Example: Check that a scale calculated by an expression at time 3.5 is the expected value of [10,50]
v ar my Prop er t y = my L ayer. sc a l e;
// false va lue of preExpression mea n s e va lua te t he expre ssion
v ar s c aleVa lue = my Prop er t y.v alu eAt Ti me (3. 5,f als e) ;
i f ( s c a l e Va lue [0 ] = = 1 0 & & s c a l e Va l u e [ 1 ] = = 5 0 ) {
a l er t( " hur r ay " ) ;
e l se {
a l er t( " o op s " );
}
Example: Keyframe a rotation from 0 to 90 and back again
The animation is 10 seconds, and the middle keyframe is at the 5 second mark. Rotation properties are stored
as a OneD value.
my Prop er t y = my L ayer. rot at i o n ;
my Prop er t y.set ValueAtTime(0, 0 );
my Prop er t y.set ValueAtTime(5, 9 0);
my Prop er t y.set ValueAtTime(10, 0);
Example: Change the keyframe values for the first three keyframes of some source text
my Prop er t y = my Tex tL ayer. so u rceTex t;
i f ( my Prop er t y.nu m Ke y s < 3 ) {
a l er t("er ror, I thoug h t there were 3 ke y f r a mes");
}
my Prop er t y. s e t Val u e At Ke y( 1 , n e w Tex t D oc u m en t ( " ke y nu m b e r 1 " ) ;
my Prop er t y. s e t Val u e At Ke y( 2 , n e w Tex t D oc u m en t ( " ke y nu m b e r 2 " ) ;
my Prop er t y. s e t Val u e At Ke y( 3 , n e w Tex t D oc u m en t ( " ke y nu m b e r 3 " ) ;
Example: Set values using the convenience syntax for position, scale, color, or source text
// Th ese t wo are e quiva lent . T he secon d fills in a defau l t of 0.
my Layer.p o sit i on.s et Valu e( [ 2 0, 3 0, 0] ) ;
my Layer.po sit i on.set Valu e([ 2 0, 3 0 ]);
// Th ese t wo are e quiva lent . T he secon d fills in a defau l t of 100 .
my Layer.scale. se t Valu e([ 50 , 50 , 10 0]);
my Layer.s c ale. se t Valu e( [ 50 , 50 ]) ;
// Th ese t wo are e quiva lent . T he secon d fills in a defau l t of 1.0
my Lig h t.color. se t Valu e([ .8 , .3 , .1 , 1.0 ]) ;
my Lig h t.color. se t Valu e([ .8 , .3 , .1 ]) ;
// Th ese t wo are e quiva lent . T he secon d crea tes a TextD o cument
116
JavaScript Reference
117
Adds a new keyframe or marker to the named property at the specified time and returns the index of the new
keyframe.
Parameters
time
The time, in seconds, at which to add the keyframe. A floating-point value. The beginning of the composition is 0.
Returns
When true, the named property is of a type whose expression can be set by a script. See also Property
expression attribute on page 117.
Type
Boolean; read-only.
When true, the named property can vary over timethat is, keyframe values or expressions can be written to
this property.
Type
Boolean; read-only.
The expression for the named property. Writeable only when c a n S e t Ex p re ss i on for the named property is
true. When you specify a value for this attribute, the string is evaluated.
If the string contains a valid expression, ex pres si onEna bl e d becomes true.
117
JavaScript Reference
118
If the string does not contain a valid expression, an error is generated, and e xp re ss i o n E n ab l e d becomes
false.
If you set the attribute to the empty string, e xp re ss i on E n ab l e d becomes false, but no error is generated.
Type
String; read/write if can S et Ex pression for the named property is true, otherwise read-only.
When true, the named property uses its associated expression to generate a value. When false, the keyframe
information or static value of the property is used. This attribute can be set to true only if c anS e tEx pres si on
for the named property is true and ex pres si on contains a valid expression string.
Type
Boolean; read/write.
Contains the error, if any, generated by evaluation of the string most recently set in e xp re ss i o n . If no
expression string has been specified, or if the last expression string evaluated without error, contains the
empty string ("").
Type
String; read-only.
When true, there is a maximum permitted value for the named property; otherwise false.
Type
Boolean; read-only.
When true, there is a minimum permitted value for the named property; otherwise false.
118
JavaScript Reference
119
Type
Boolean; read-only.
Returns true if the named property can be interpolated using the specified keyframe interpolation type.
Parameters
type
Ke y fr am eIn ter p o l at i on Ty p e .L I N E A R
Ke y fr am e In t e r p o l a t i on Ty p e .B E Z I E R
Ke y fr am eIn ter p o l at i on Ty p e .H OL D
Returns
Boolean.
When true, the named property defines a spatial value. Examples are position and effect point controls.
Type
Boolean; read-only.
When true, the named property is time varyingthat is, it has keyframes or an enabled expression. When this
attribute is true, the attribute ca n Var y O verTi m e must also be true.
Type
Boolean; read-only.
119
JavaScript Reference
120
Ke y fr am eIn ter p o la t i on Ty p e .L I N E A R
Ke y fr ameIn ter p o la t ion Ty p e .BE ZIER
Ke y fr am eIn ter p o la t i on Ty p e .H OL D
The index for the keyframe. An integer in the range [0..nu m Ke y s ], as returned by the ad d Ke y or n ea re st Ke y -
In dex method.
Returns
Returns the incoming spatial tangent for the specified keyframe, if the named property is spacial (that is, the
value type is TwoD _ S PAT I AL or T hree D_ S PAT I AL ).
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..nu m Ke y s ], as returned by the ad d Ke y or n ea re st Ke y -
In dex method.
Returns
values.
If the property value type is proper t y Valu eTy p e.T hree D_SPATIAL , the array contains 3 floating-point
values.
If the property value type is neither of these types, an exception is generated.
120
JavaScript Reference
121
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
121
JavaScript Reference
122
Returns
values.
If the property value type is proper t y Valu eTy p e.T hree D_SPATIAL , the array contains 3 floating-point
values.
If the property value type is neither of these types, an exception is generated.
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Returns true if the specified keyframe is roving. The first and last keyframe in a property cannot rove; if you
try to set roving for one of these, the operation is ignored, and ke y Rov i n g ( ) continues to return false.
If the property value type is neither TwoD _ S PAT I AL nor T h re e D _ S PAT I A L , an exception is generated.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Boolean.
122
JavaScript Reference
123
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Boolean.
Returns true if the specified keyframe has spatial auto-Bezier interpolation. (This type of interpolation affects
this keyframe only if ke y Sp at i a lC on t i nu ous (k e y In d e x ) is also true.)
If the property value type is neither TwoD _ S PAT I AL nor T h re e D _ S PAT I A L , an exception is generated.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Boolean.
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Boolean.
123
JavaScript Reference
124
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Boolean.
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Boolean.
Finds the specified keyframe or marker and returns the time at which it occurs.
If no keyframe or marker can be found that matches the argument, this method generates an exception, and
an error is displayed.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or
n e a re s t Ke y In d ex method.
m a r ke r Com m e n t
The comment string attached to a marker (see MarkerValue comment attribute on page 96).
124
JavaScript Reference
125
Returns
Floating-point value.
Finds the specified keyframe or marker and returns its current value.
If no keyframe or marker can be found that matches the argument, this method generates an exception, and
an error is displayed.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or
n e a re s t Ke y In d ex method.
m a r ke r Com m e n t
The comment string attached to a marker (see MarkerValue comment attribute on page 96).
Returns
Floating-point value.
The maximum permitted value of the named property. If the h a s Ma x attribute is false, an exception occurs,
and an error is generated.
Type
The minimum permitted value of the named property. If the ha sMin attribute is false, an exception occurs,
and an error is generated.
Type
125
JavaScript Reference
126
Returns
Integer.
The number of keyframes in the named property. If the value is 0, the property is not being keyframed.
Type
Integer; read-only.
The position index of the named property. The first property is at index position 1.
Type
Integer; read-only.
The type of value stored in the named property. The Proper t y ValueTy p e enumeration has one value for each
type of data that can be stored in or retrieved from a property. Each type of data is stored and retrieved in a
different kind of structure. All property objects store data according to one of these categories.
For example, a 3D spatial property (such as a layer's position) is stored as an array of three floating point
values. When setting a value for position, pass in such an array, as follows:
my l ayer. pro p e r t y (" p o si t i o n " ). se t Valu e ([ 1 0 ,2 0 ,0] ) ;
In contrast, a shape property (such as a layer's mask shape) is stored as a Shape object. When setting a value
for a shape, pass a Shape object, as follows:
v ar my Sh ap e = n ew S h ap e () ;
126
JavaScript Reference
127
Stores no data.
A floating-point value.
Unimplemented type; you cannot get or set values for properties with this
type.
Removes the specified keyframe from the named property. If no keyframe with the specified index exists,
generates an exception and displays an error.
When a keyframe is removed, the remaining index numbers change. To remove more than one keyframe, you
must start with the highest index number and work down to the lowest to ensure that the remaining indices
reference the same keyframe after each removal.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Nothing.
127
JavaScript Reference
128
The indices of all the selected keyframes in the named property. If no keyframes are selected, or if the property
has no keyframes, returns an empty array.
Type
Sets the in and out interpolation types for the specified keyframe.
Parameters
i n Ty p e
Ke y fr am eIn ter p o l at i on Ty p e .L I N E A R
Ke y fr am e In t e r p o l a t i on Ty p e .B E Z I E R
Ke y fr am eIn ter p o l at i on Ty p e .H OL D
o u t Ty p e
(Optional) The outgoing interpolation type. If not supplied, the out type is set to the i n Ty p e
value. A Ke y f r a m eIn ter p ol a t ion Ty p e enumerated value; one of:
Ke y fr am eIn ter p o l at i on Ty p e .L I N E A R
Ke y fr am e In t e r p o l a t i on Ty p e .B E Z I E R
Ke y fr am eIn ter p o l at i on Ty p e .H OL D
Returns
Nothing.
Turns roving on or off for the specified keyframe. The first and last keyframe in a property cannot rove; if you
try to set roving for one of these, the operation is ignored, and ke y Rov i n g ( ) continues to return false.
If the property value type is neither TwoD _ S PAT I AL nor T h re e D _ S PAT I A L , an exception is generated.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke y s ], as returned by the a d dKe y or n eares tKe y In dex method.
newVal
128
JavaScript Reference
129
Returns
Nothing.
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Returns
Nothing.
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Returns
Nothing.
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
129
JavaScript Reference
130
Returns
Nothing.
Sets the incoming and outgoing tangent vectors for the specified keyframe.
If the property value type is neither TwoD _ S PAT I AL nor T h re e D _ S PAT I A L , an exception is generated.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
If the property value type is prop er t y Va lueTy p e .Two D_ S PATIAL , the array contains 2 values.
If the property value type is prop er t y Va lueTy p e .Th re eD _SPATIA L , the array contains 3 values.
o u t Ta n gen t
(Optional) The outgoing tangent vector. If not supplied, the out tangent is set to the i n Ta n g e n t value. An
array of 2 or 3 floating-point values.
If the property value type is prop er t y Va lueTy p e .Two D_ S PATIAL , the array contains 2 values.
If the property value type is prop er t y Va lueTy p e .Th re eD _SPATIA L , the array contains 3 values.
Returns
Nothing.
Turns temporal auto-Bezier interpolation on or off for the specified keyframe. When this is turned on, it
affects this keyframe only if ke y S p a t i a l Con t i nu o u s (ke yInd ex) is also true.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Returns
Nothing.
130
JavaScript Reference
131
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
Returns
Nothing.
Sets the incoming and outgoing temporal ease for the specified keyframe. See KeyframeEase object on
page 79.
Parameters
ke y In dex
The index for the keyframe. An integer in the range [0..nu m Ke y s ], as returned by the a dd Ke y or
n ea re st Ke y In dex method.
i n Tem p or a l E a se
If the property value type is proper t yVa lue Ty p e.TwoD _SPATIA L , the array contains 2
objects.
If the property value type is proper t yVa lue Ty p e.T hreeD _SPATIAL , the array contains 3
objects.
(Optional) The outgoing temporal ease. If not supplied, the outgoing ease is set to the i n Tem p o r a l E as e value. An array of 1, 2, or 3 KeyframeEase objects.
If the property value type is proper t yVa lue Ty p e.TwoD _SPATIA L , the array contains 2
objects.
If the property value type is proper t yVa lue Ty p e.T hreeD _SPATIAL , the array contains 3
objects.
Nothing.
131
JavaScript Reference
132
A value appropriate for the type of property being set; see Property propertyValueType attribute on page 126.
Returns
Nothing.
The index for the keyframe. An integer in the range [0..num Ke ys ], as returned by the ad d Ke y or n ear-
A value appropriate for the type of property being set; see Property propertyValueType attribute on
page 126.
Returns
Nothing.
Sets the value of a keyframe at the specified time. Creates a new keyframe for the named property, if one does
not currently exist for the specified time, and sets its value.
Parameters
time
n e w Va lu e
A value appropriate for the type of property being set; see Property propertyValueType
attribute on page 126.
132
JavaScript Reference
133
Returns
Nothing.
Sets values for a set of keyframes at specified of times. Creates a new keyframe for the named property, if one
does not currently exist for a specified time, and sets its value.
Times and values are expressed as arrays; the arrays must be of the same length.
Parameters
t i m es
An array of times, in seconds. Each time is a floating-point value. The beginning of the composition is 0.
n e w Va lu e s
A array of values appropriate for the type of property being set; see Property propertyValueType attribute on page 126.
Returns
Nothing.
String; read-only.
The type of value returned depends on the property value type. See examples for Property object on
page 113.
Type
A value appropriate for the type of the property (see Property propertyValueType attribute on page 126);
read-only.
133
JavaScript Reference
134
pre E x pres si o n
If the property has an expression and this is true, return the value for the specified time without
applying the expression to it. When false, return the result of evaluating the expression for the
specified time.
Ignored if the property does not have an associated expression.
Returns
A value appropriate for the type of the property (see Property propertyValueType attribute on page 126).
134
JavaScript Reference
135
PropertyBase object
a pp. pro je c t .i tem ( i n d e x) .l ayer (i n de x ). prop e r t y Sp ec
Description
Properties are accessed by name through layers, using various kinds of expression syntax, as controlled by
application preferences. For example, the following are all ways of access properties in the Effects group:
v ar effe ct 1 = app.proj ec t. item(1 ). layer( 1 ) . e f fe c t ( " Ad d Gr a i n " ) ( " Vi e w i n g Mo d e " ) ;
v ar effe ct 1a ga in = a pp. pro je c t .item(1).layer (1 ). effec t.a ddGr ain.v ie w i ngMo de ;
v ar ef fe c t 1a g a in too = a pp. pro je c t .i tem ( 1) .l ayer (1 )( " Ef fe c t s") .a d dGr a i n .v i ew i ngMo de;
v ar ef fe c t 1a ga in too 2 = a pp.proje c t.i tem (1 ).l ayer( 1) ("Ef fe c t s " )( "Ad d Gr ai n")( "Vie w i ng Mo de ");
methods are available when working with properties and property groups. See Property object on
page 113 and PropertyGroup object on page 142.
Reference invalidation
When something occurs that changes an object sufficiently for the reference to become invalid, script references to that object can generate errors. In simple cases this is straightforward. For example, if you delete an
object, a reference to the deleted object generates the warning "Object is Invalid":
v ar layer 1 = app.proj ec t. item(1 ). layer(1);
layer 1.remove();
a l er t ( l ayer 1. n a m e ) ; / / i nv a l i d ref e ren ce to d e l e te d o b j e c t
A less straightforward case is when a property is removed from a property group. In this case, After Effects
generates the "Object is Invalid" error when you subsequently reference that item or other items in the group,
because their index positions have changed. For example:
v ar effe ct 1 = app.proj ec t. item(1 ). layer(1).effe c t (1 );
v ar effe ct 2 = app.proj ec t. item(1 ). layer(1).effe c t (2 );
v ar ef fe ct 2p ar am = app.proj ec t. item(1 ). layer( 1) .ef fe c t (2 ). blend Wi t hO r ig in al;
effe ct 1.remove();
a l er t( e f fe c t 2 .n a m e ) ; / / i nv al i d re feren ce b e c au se g ro u p in dex p o s i t i on s h ave cha n g e d
Attributes
Attribute
Reference
Description
name
matchNam e
A special name for the property used to build unique naming paths.
135
JavaScript Reference
136
Attribute
Reference
Description
prop er t y Index
prop er t y D ep t h
PropertyBase propertyDepth attribute The number of levels of parent groups between this property and
on page 139
the containing layer.
prop er t y Ty p e
i s Mod i fi e d
When true, the property has been changed since its creation.
c a n S e t E n a bl e d
PropertyBase canSetEnabled attribute When true, the user interface displays an eyeball icon for this propon page 137
erty.
e n a bl e d
a c t ive
e l id ed
i s E ff e c t
i s Mas k
s e l e c te d
Methods
Method
Reference
Description
Gets the parent group for this property.
rem ove( )
m oveTo( )
du pl i c ate( )
When true, this property is active. For a layer, this corresponds to the setting of the eyeball icon. For an effect
and all properties, it is the same as the ena b le d attribute.
Type
136
JavaScript Reference
137
When true, you can set the e n a bl e d attribute value. Generally, this is true if the user interface displays an
eyeball icon for this property; it is true for all layers.
Type
Boolean; read-only.
If this property is a child of an indexed group, creates and returns a new PropertyBase object with the same
attribute values as this one.
If this property is not a child of an indexed group, the method generates an exception and displays an error.
An indexed group has the type Prop er t y Ty p e .I N D E XE D_ G RO UP ; see PropertyBase propertyType attribute
on page 140.
Parameters
None.
Returns
PropertyBase object.
When true, this property is a group used to organize other properties. The property is not displayed in the
user interface and its child properties are not indented in the Timeline panel.
For example, for a text layer with two animators and no properties twirled down, you might see:
Tex t
Pa th O p t i on s
More O p t i on s
Anim ator 1
Anim ator 2
In this example, Animator 1 and Animator 2 are contained in a PropertyBase called Text Animators.
This parent group is not displayed in the user interface, and so the two child properties are not indented in
the Timeline panel.
Type
Boolean; read-only.
137
JavaScript Reference
138
When true, this property is enabled. It corresponds to the setting of the eyeball icon, if there is one; otherwise,
the default is true.
Type
Boolean; read-only.
Boolean; read-only.
When true, this property has been changed since its creation.
Type
Boolean; read-only.
A special name for the property used to build unique naming paths. The match name is not displayed, but you
can refer to it in scripts. Every property has a unique match-name identifier. Match names are stable from
version to version regardless of the display name (the n am e attribute value) or any changes to the application.
Unlike the display name, it is not localized.
138
JavaScript Reference
139
An indexed group may not have a nam e value, but always has a m a tch Na m e value. (An indexed group has the
type Pro p e r t y Ty p e. I N D E X E D _ G RO U P ; see PropertyBase propertyType attribute on page 140.)
Type
String; read-only.
The new index position at which to place this property in its group. An integer.
Returns
Nothing.
The display name of the property. (Compare PropertyBase matchName attribute on page 138.)
It is an error to set the n a m e value if the property is not a child of an indexed group (that is, a property group
that has the type Pro p e r t y Ty p e. I N D E X E D _ G RO U P ; see PropertyBase propertyType attribute on page 140).
Type
The property group that is the immediate parent of this property, or null if this PropertyBase is a layer.
Type
139
JavaScript Reference
140
Description
The number of levels of parent groups between this property and the containing layer. The value 0 for a layer.
Type
Integer; read-only.
Gets the PropertyGroup object for an ancestor group of this property at a specified level of the parent-child
hierarchy.
Parameters
co un tUp
Optional. The number of levels to ascend within the parent-child hierarchy. An integer in the
range [1..prop er t y D ep th ]. Default is 1, w hich gets the immediate parent.
Returns
The position index of this property within its parent group, if it is a child of an indexed group (a property
group that has the type Pro p e r t y Ty p e. I N D E X E D _ G RO U P ; see PropertyBase propertyType attribute on
page 140).
Type
Integer; read-only.
Prop er t y Ty p e .I N D E XE D_ G RO UP
A property group whose members have an editable name and an index. Effects
and masks are indexed groups. For example, the m a s k s property of a layer
refers to a variable number of individual masks by index number.
140
JavaScript Reference
141
A property group in which the member names are not editable. Layers are
named groups.
Removes this property from its parent group. If this is a property group, it removes the child properties as well.
This method is valid only for children of indexed groups; if it is not, or if the index value is not valid, the
method generates an exception and displays an error. (An indexed group has the type Prop ert y Ty p e. I N DE XE D _ G ROU P ; see PropertyBase propertyType attribute on page 140.)
This method can be called on a text animation property (that is, any animator that has been set to a text layer).
Parameters
None.
Returns
Nothing.
When true, this property is selected. Set to true to select the property, or to false to deselect it.
Sampling this attribute repeatedly for a large number of properties can slow down system performance. To
read the full set of selected properties of a composition or layer, use the se l e c te d Prop er t i es attribute of a
Comp or Layer object.
Type
141
JavaScript Reference
142
PropertyGroup object
a pp. pro je c t .i tem ( i n d e x) .l ayer (i n de x ). prop e r t y Grou p Sp e c
Description
The PropertyGroup object represents a group of properties. It can contain Property objects and other
PropertyGroup objects. Property groups can be nested to provide a parent-child hierarchy, with a Layer object
at the top (root) down to a single Property object, such as the mask feather of the third mask. To traverse the
group hierarchy, use PropertyBase methods and attributes; see PropertyBase propertyGroup() method on
page 140.
For examples of how to access properties and property groups, see PropertyBase object on page 135.
PropertyGroup is a subclass of PropertyBase. All methods and attributes of PropertyBase, in addition to
those listed below, are available when working with PropertyGroup. See PropertyBase object on page 135.
PropertyGroup is a base class for MaskPropertyGroup. PropertyGroup attributes and methods are available
when working with mask groups. See MaskPropertyGroup object on page 97.
Attributes
Attribute
Reference
Description
nu m Prop er t i es
PropertyGroup numProperties attribute on page 143 The number of indexed properties in the group.
Methods
Method
Reference
Description
prop er t y ( )
c a n Ad dPro p e r t y ()
a d dProp er t y ()
Creates and returns a PropertyBase object with the specified name, and adds it to this group.
In general, you can only add properties to an indexed group (a property group that has the type
Prop er t y Ty p e .I N D E XE D_ G RO UP ; see PropertyBase propertyType attribute on page 140) The only
exception is a text animator property, which can be added to a named group (a property group that has the
type Prop er t y Ty p e.NA ME D _ G ROU P) .
If this method cannot create a property with the specified name, it generates an exception. To check that you
can add a particular property to this group, call c a n Ad dPro p e r t y before calling this method. (See PropertyGroup canAddProperty() method on page 143.)
142
JavaScript Reference
143
Parameters
name
The display name or match name of the property to add. (See PropertyBase matchName attribute on page 138).
The following names are supported:
Any match name for a property that can be added through the user interface. For example, ADBE Mask Atom,
ADBE Paint Atom, ADBE Text Position, ADBE Text Anchor Point.
Returns
PropertyBase object.
Returns true if a property with the given name can be added to this property group. For example, you can only
add mask to a mask group. The only legal input arguments are mask or ADBE Mask Atom.
m a sk Gro u p. ca n Ad d Prop e r t y ( " m as k" ) ; / / re tu r n s t r u e
m a sk Gro u p. ca n Ad d Prop e r t y ( " A DB E Ma s k Ato m " ) ; / / re tu r n s t r u e
m a s k Gro u p. ca n Ad d Prop e r t y ( " bl e n d " ) ; / / re t u r n s fa l s e
Parameters
name
The display name or match name of the property to be checked. (See PropertyGroup addProperty() method on page 142).
Returns
Boolean.
Integer; read-only.
143
JavaScript Reference
144
Finds and returns a child property of this group, as specified by either its index or name.
A name specification can use the same syntax that is available with expressions. The following are all allowed
and are equivalent:
my l ayer. p o s it i o n
my l ayer (" p o si t i o n " )
my l ayer. prop er t y ("p o si t i on")
my l ayer (1 )
my l ayer. prop er t y (1 )
Some properties of a layer, such as position and zoom, can be accessed only by name.
When using the name to find a property that is multiple levels down, you must make more than one call to
this method. For example, the following call searches two levels down, and returns the first mask in the mask
group:
my L ayer.p rop e r t y ( " A D BE Mas ks " ) .prop e r t y ( 1 )
Parameters
i n dex
The index for the child property, in this is an indexed group. An integer in the range [0..nu m Prop er -
t i es ].
name
Returns
PropertyBase object or null if no child property with the specified string name is found.
Properties accessible by name
From any Layer
144
JavaScript Reference
145
From an AVLayer
"Zoom" or "zoom"
"Depth of Field" or "depthOfField"
"Focus Distance" or "focusDistance"
"Aperture" or "aperture"
"Blur Level" or "blurLevel"
"Intensity" or "intensity"
"Color" or "color"
"Cone Angle" or "coneAngle"
"Cone Feather" or "coneFeather"
"Shadow Darkness" or "shadowDarkness"
"Shadow Diffusion" or "shadowDiffusion"
"Casts Shadows" or "castsShadows"
From a 3D layer
145
JavaScript Reference
146
Examples
1 If a layer named myLayer has a Box Blur effect, you can retrieve the effect in any of the following ways:
my L ayer.p rop e r t y ( E f fe c t s ) .prop e r t y ( B ox Blu r );
my L ayer.p rop e r t y ( E f fe c t s ) .prop e r t y ( b ox Blur ) ;
my L ayer.p rop e r t y ( E f fe c t s ) .prop e r t y ( A D BE B ox Bl u r ) ;
2 If a layer named myLayer has a mask named Mask 1 you can retrieve it as follows:
my L ayer.p rop e r t y ( Ma sk s ) .p rop e r t y ( Ma sk 1 ) ;
3 To get a Bulge Center value from a Bulge effect, you can use either of the following:
my L ayer.p rop e r t y ( E f fe c t s ) .prop e r t y ( Bu l g e ) .prop e r t y ( Bul g e Cen te r ) ;
my L ayer.p rop e r t y ( E f fe c t s ) .prop e r t y ( Bu l g e ) .prop e r t y ( b u l g e Ce n ter ) ;
146
JavaScript Reference
147
RenderQueue object
a pp. pro je c t .renderQ ueue
Description
The RenderQueue object represents the render automation process, the data and functionality that is available
through the Render Queue panel of a particular After Effects project. Attributes provide access to items in the
render queue and their render status. Methods can start, pause, and stop the rendering process.
The RenderQueueItem object provides access to the specific settings for an item to be rendered. See RenderQueueItem object on page 150.
Attributes
Attribute
Reference
Description
ren der in g
nu m Item s
i te m s
Methods
Method
Reference
Description
s h ow Win dow( )
ren der( )
p au se Re n der in g ()
RenderQueue pauseRendering()
method on page 148
s to pRen d e r i n g ( )
RenderQueue stopRendering()
method on page 149
i te m ( )
The position index of the item. An integer in the range [0..num Item s ].
Returns
RenderQueueItem object.
147
JavaScript Reference
148
A collection of all items in the render queue. See RenderQueueItem object on page 150.
Type
Integer; read-only.
Pauses the current rendering process, or continues a paused rendering process. This is the same as clicking
Pause in the Render Queue panel during a render. You can call this method from an o n S t a t u sC h a n ge d or
o n E r ror callback . See RenderQueueItem onStatusChanged attribute on page 152 and Application onError
attribute on page 26.
Parameters
p au se
Returns
Nothing.
Starts the rendering process. This is the same as clicking Render in the Render Queue panel. The method does
not return until the render process is complete. To pause or stop the rendering process, call pa useRender i ng()
or s top Ren de r i n g ( ) from an o n E r ror or o n S t a t u sC h a n g e d callback.
To respond to errors during the rendering process, define a callback function in a pp. on E r ror ; see Appli-
function in RenderQu eu eItem.onSta tusChange d in the associated RenderQueueItem object; see RenderQueueItem onStatusChanged attribute on page 152.
148
JavaScript Reference
149
Parameters
None.
Returns
Nothing.
When true, the rendering process is in progress or paused. When false, it is stopped.
Type
Boolean; read-only.
When true, show the Render Queue panel. When false, hide it.
Returns
Nothing.
Stops the rendering process. This is the same as clicking Stop in the Render Queue panel during a render. You
can call this method from an o n S t a t u sC h a n g e d or o n E r ror callback . See RenderQueueItem onStatusChanged attribute on page 152 and Application onError attribute on page 26.
Parameters
None.
Returns
Nothing.
149
JavaScript Reference
150
RenderQueueItem object
a pp. pro je c t .renderQ ueue. items( i n d e x)
Description
The RenderQueueItem object represents an individual item in the render queue. It provides access to the
specific settings for an item to be rendered.
Attributes
Attribute
Reference
Description
nu m Out p utMo du le s
RenderQueueItem numOutputModules
attribute on page 152
ren der
s ta r t Ti m e
e l ap se d S e co n d s
RenderQueueItem elapsedSeconds
attribute on page 151
t i m e S p an S t ar t
RenderQueueItem timeSpanStart
attribute on page 155
t i m eS p an D ur at i o n
RenderQueueItem timeSpanDuration
attribute on page 155
s ki p Fr a m e s
com p
outputMo du le s
RenderQueueItem outputModules
attribute on page 153
tem pl a tes
s ta tu s
onStatusChanged
RenderQueueItem onStatusChanged
attribute on page 152
l o g Ty p e
Methods
Method
Reference
Description
outputMo du le ()
rem ove( )
a pp ly Te m p l ate ( )
150
JavaScript Reference
151
Method
Reference
Description
du pl i c ate
Applies a Render Settings template to the item. See also RenderQueueItem saveAsTemplate() method on
page 154 and RenderQueueItem templates attribute on page 155.
Parameters
tem pl a teNam e
Returns
Nothing.
The composition that will be rendered by this render-queue item. To change the composition, you must delete
this render-queue item and create a new one.
Type
None.
Returns
RenderQueueItem object.
151
JavaScript Reference
152
Type
A log type for this item, indicating which events should be logged while this item is being rendered.
Type
Integer; read-only.
The name of a callback function that is called whenever the value of the Ren derQ ueueItem.sta tu s attribute
changes. See RenderQueueItem status attribute on page 154.
You cannot make changes to render queue items or to the application while rendering is in progress or paused;
you can, however, use this callback to pause or stop the rendering process. See RenderQueue pauseRendering() method on page 148 and RenderQueue stopRendering() method on page 149.
See also Application onError attribute on page 26.
Type
152
JavaScript Reference
153
The position index of the ouptut module. An integer in the range [0..num Out putMo dule s ].
Returns
OutputModule object.
None.
Returns
Nothing.
When true, the item will be rendered when the render queue is started. When set to true, the Ren derQ ueueItem.st atu s is set to RQ Item St at us .QU E UE D . When set to false, st at us is set to RQ Item S ta tu s. U N QU E U E D .
Type
Boolean; read/write.
153
JavaScript Reference
154
Saves the items current render settings as a new template with the specified name.
Parameters
name
Returns
Nothing.
The number of frames to skip when rendering this item. Use this to do rendering tests that are faster than a
full render.
A value of 0 skip no frames, and results in regular rendering of all frames. A value of 1 skips every other frame.
This is equivalent to "rendering on twos." Higher values skip a larger number of frames.
The total length of time remains unchanged. For example, if skip has a value of 1, a sequence output would
have half the number of frames and in movie output, each frame would be double the duration.
Type
Date object, or null if the item has not started rendering; read-only.
154
JavaScript Reference
155
Type
RQ Ite m S t a t u s . N E E D S _ O U T P U T
RQ Item St at us .U N QUE U E D
Item is listed in the Render Queue panel but composition is not ready to render.
RQ Item St at us .QU E UE D
RQ Item St at us .RE N D E RI N G
Composition is rendering
RQ Item St at us .E RR _ STO P PE D
RQ Item St at us .D ON E
The names of all Render Settings templates available for the item. See also RenderQueueItem saveAsTemplate()
method on page 154.
Type
The duration in seconds of the composition to be rendered. The duration is determined by subtracting the
start time from the end time. Setting this value is the same as setting a custom end time in the Render Settings
dialog box.
Type
The time in the composition, in seconds, at which rendering will begin. Setting this value is the same as setting
a custom start time in the Render Settings dialog box.
Type
155
JavaScript Reference
156
RQItemCollection object
a pp. pro je c t .renderQ ueue. items
Description
The RQItemCollection contains all of the render-queue items in a project, as shown in the Render Queue
panel of the project. The collection provides access to the RenderQueueItem objects, but does not provide any
additional functionality. The first RenderQueueItem object in the collection is at index position 1. See
RenderQueueItem object on page 150
RQCollection is a subclass of Collection. All methods and attributes of Collection are available when
156
JavaScript Reference
157
Settings object
Description
The Settings object provides an easy way to manage settings for scripts. The settings are saved in the After
Effects preferences file and are persistent between application sessions. Settings are identified by section and
key within the file, and each key name is associated with a value. In the preferences file, section names are
enclosed in brackets and quotation marks, and key names are listing in quotation marks below the section
name. All values are strings.
You can create new settings with this object, as well as accessing existing settings.
Methods
Method
Reference
Description
s aveS e t t in g ()
g e t S e tt i n g ( )
h aveS e tt i n g ( )
ke y Na m e
Returns
String.
Example
If you have saved a setting named with the key name Aligned Clone in the Eraser - Paint Settings section,
you can retrieve the value with this script:
v ar n = ap p.s e tt i n g s .get S e tt i n g( "Er a ser - Pa i n t S e tt i n g s ", "Ali g n e d Clone ") ;
a l er t ( " T h e s e t t i n g i s " + n ) ;
Returns true if the specified scripting preferences item exists and has a value.
157
JavaScript Reference
158
Parameters
s e c t i on Na m e
ke y Na m e
Returns
Boolean.
ke y Na m e
v alu e
Returns
Nothing.
158
JavaScript Reference
159
Shape object
a pp. pro je c t .i tem ( in d e x) .layer(i n de x ). prop er t y (i n de x ). prop e r t y ( " m as kS h a p e " ). v al u e
Description
The Shape object encapsulates information describing the outline shape of a Mask. It is the value of a
maskShape AE property. Use the constructor, new S h a p e ( ) , to create a new, empty Shape object, then set
the attributes individually to define the shape.
A shape has a set of anchor points, or vertices, and a pair of direction handles, or tangent vectors, for each
anchor point. A tangent vector (in a non-RotoBezier mask) determines the direction of the line that is drawn
to or from an anchor point. There is one incoming tangent vector and one outgoing tangent vector associated
with each vertex in the shape.
A tangent value is a pair of x,y coordinates specified relative to the associated vertex. For example, a tangent
of [-1,-1] is located above and to the left of the vertex and has a 45 degree slope, regardless of the actual
location of the vertex. The longer a handle is, the greater its influence; for example, an incoming shape
segment stays closer to the vector for an i n Ta n g e n t of [-2,-2] than it does for an in Tan g en t of
[-1,-1], even though both of these come toward the vertex from the same direction.
If a shape is not closed, the i n Ta n g e n t for the first vertex and the o ut Ta n g en t for the final vertex are ignored.
If the shape is closed, these two vectors specify the dirction handles of the final connecting segment out of the
final vertex and back into the first vertex.
RotoBezier masks calculate their tangents automatically. (See MaskPropertyGroup rotoBezier attribute on
page 98.) If a shape is used in a RotoBezier mask, the tangent values are ignored. This means that, for
RotoBezier masks, you can construct a shape by setting only the ver t ices attribute and setting both i n Tan ge n t s
and o u t Ta n gen t s to null. When you access the new shape, its tangent values are filled with the automaticallycalculated tangent values.
Example: Create a square mask
A square is a closed shape with 4 vertices. The i n Tan g e n t s and o u t Ta n g e n t s for connected straight-line
segments are 0, the default, and do not need to be explicitly set.
v ar my Sh ap e = n ew S h ap e () ;
my Sh ap e .ver t ice s = [ [ 0 ,0 ], [ 0 , 1 ] , [ 1 ,1 ], [ 1 , 0 ] ];
my Sh ap e.cl o se d = t r ue;
Example: Create a U shaped mask
A "U" is an open shape with the same 4 vertices used in the square:
v ar my Sh ap e = n ew S h ap e () ;
my Sh ap e .ver t ice s = [ [ 0 ,0 ], [ 0 , 1 ] , [ 1 ,1 ], [ 1 , 0 ] ];
my Sh ap e.clo se d = false;
Example: Create an oval
159
JavaScript Reference
160
Attributes
Attribute
Reference
Description
cl o se d
ver t ices
i n Ta n g e n ts
o u t Ta n gen t s
When true, the first and last vertices are connected to form a closed curve. When false, the closing segment is
not drawn.
Type
Boolean; read/write.
The incoming tangent vectors, or direction handles, associated with the vertices of the shape. Specify each
vector as an array of two floating-point values, and collect the vectors into an array the same length as the
ver t ices array.
Each tangent value defaults to [0,0]. When the mask shape is not RotoBezier, this results in a straight line
segment.
If the shape is in a RotoBezier mask, all tangent values are ignored and the tangents are automatically calculated.
Type
The outgoing tangent vectors, or direction handles, associated with the vertices of the shape. Specify each
vector as an array of two floating-point values, and collect the vectors into an array the same length as the
ver t ices array.
Each tangent value defaults to [0,0]. When the mask shape is not RotoBezier, this results in a straight line
segment.
If the shape is in a RotoBezier mask, all tangent values are ignored and the tangents are automatically calculated.
160
JavaScript Reference
161
Type
The anchor points of the shape. Specify each point as an array of two floating-point values, and collect the
point pairs into an array for the complete set of points. For example:
my Sh ap e .ver t ice s = [ [ 0 ,0 ], [ 0 , 1 ] , [ 1 ,1 ], [ 1 , 0 ] ];
Type
161
JavaScript Reference
162
SolidSource object
a pp. pro je c t .i tem ( in d e x) . m a i n S o u rce
a pp. pro je c t .i tem ( in d e x) .p roxySo urce
Description
those listed below, are available when working with SolidSource. See FootageSource object on page 65.
Attributes
Attribute
Reference
Description
co lor
The color of the solid, expressed as red, green, and blue values.
Type
Array of three floating-point values, [R, G, B], in the range [0.0..1.0]; read/write.
162
JavaScript Reference
163
System object
s ys te m
Description
The System object provides access to attributes found on the users system, such as the user name and the
name and version of the operating system. It is available through the s ys te m global variable.
Example
a l er t ( "Your O S is " + system.osna m e + " r unning version " + system.o sversion );
con f i r m ( " Yo u a re : " + s ys te m . u s e r Na m e + " r un n i n g o n " + s y s t e m . m a ch i n e Na m e + " . " ) ;
Attributes
Attribute
Reference
Description
u s e r Nam e
m a chi n e Na m e
System machineName attribute on page 163 The name of the host computer.
o s Nam e
o s Ver s i o n
Method
Reference
Description
c a l l Sy s te m ( )
Methods
Executes a system command, as if you had typed it on the operating systems command line. Returns whatever
the system outputs in response to the command, if anything.
Parameters
c m d L i n e To Exec u te
Returns
String; read-only.
163
JavaScript Reference
164
String; read-only.
String; read-only.
String; read-only.
164
JavaScript Reference
165
TextDocument object
n e w Tex t D o c u m e n t (d oc Te x t )
a pp. pro je c t .i tem ( in d e x) .layer(i n de x ). prop er t y ( "So urce Text").v alu e
Description
The TextDocument object stores a value for a TextLayer's Source Text property. Create it with the constructor,
passing the string to be encapsulated.
Examples
This sets a value of some source text and displays an alert showing the new value:
v ar my Tex t D o c u m en t = n e w Tex t D o c u m en t( " Ha p p y C a ke" ) ;
my Tex t L ayer.p ro p e r t y( " S o u rc e Tex t " ) . s e t Val u e ( my Tex t D o c u m e n t ) ;
a l er t( my Tex t L ayer.p rop er t y ( " S ou rce Tex t" ) .va lue );
This sets keyframe values for text that show different words over time:
v a r tex tPro p = myTex t L ayer.prop e r t y ( " S o u rce Text " ) ;
tex tPro p. se tVa lue At Ti m e ( 0 , n e w Tex t D o c u m e n t ( " Hap py " ) ) ;
tex tPro p. se tVa lue At Ti m e ( . 3 3 , n e w Tex tD o c u m e n t (" c a ke" ) );
tex tPro p. se tVa lue At Ti m e ( . 6 6 , n e w Tex tD o c u m e n t (" i s " )) ;
tex tPro p. se tVa lue At Ti m e ( 1 , n e w Tex t D o c u m e n t ( " yu m my! " )) ;
Attributes
Attribute
Reference
Description
tex t
The text value for the text layers Source Text property.
Type
String; read/write.
165
JavaScript Reference
166
TextLayer object
a pp. pro je c t .i tem ( in d e x) .l ayer(i n de x )
Description
The TextLayer object represents a text layer within a composition. Create it using the LayerCollection objects
a d dTex t method; see LayerCollection addText() method on page 93. It can be accessed in an items layer
collection either by index number or by a name string.
TextLayer is a subclass of AVLayer, which is a subclass of Layer. All methods and attributes of AVLayer and
Layer are available when working with TextLayer. See Layer object on page 81 and AVLayer object on
page 39.
AE Properties
TextLayer defines no additional attributes, but has the following AE properties and property groups, in
addition to those inherited from AVLayer:
Tex t
S o u rce Tex t
Pa th O pt i on s
Pa th
Re verse Path
Per p en di c ul a r To Pa th
Force A l i g n m e n t
F i r s t Ma r g i n
L a s t Mar g i n
More O p t i on s
Anchor Point Grouping
Gro up in g Al i g n m e n t
F i l l & S t roke
In ter- C ha r a c ter Bl en d i n g
Anim ators
Unused Properties and Attributes
The Ti m e Rem a p and Mot i on Tr ac kers properties, inherited from AVLayer, are not applicable to text layers,
and their related AVLayer attributes are not used:
c a n S e t Ti m e Rem a p E n a bl e d
t i m eRem ap E n ab l e d
t r ackMat teTy p e
i s Tr a ck Ma tte
h as Tr a ck Ma tte
166
Examples
The following sample scripts are included on your CD. This section provides an overview of what they do and
a step-by-step breakdown of how they work.
This set of examples is by no means exhaustive, but it does demonstrate some of scriptings 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
h t t p : / / s h a re . s t u d i o.a d o b e .com , and choose Script in the Adobe After Effects section.
Apply effect
This simple example requires that the user select an AVLayer and, if that condition is met, sets a 10-pixel Fast
Blur to the selected layer (or layers), with Repeat Edge Pixels set to true. For a localized application, the effect
name, Fast Blur, and the names of its properties blurriness and repeatEdgePixels would need to be
localized.
This script does the following:
checks that at least one selected layer can have effects applied to it;
adds Fast Blur to any selected layer that can have it;
sets Blurriness to 10 and turns on Repeat Edge Pixels;
returns a boolean stating whether the effect was added;
starts an undo group so that if the effect is being applied to more than one layer, the entire script operation
167
Examples
168
}
/ / Re t u r n a b oo le an s ay i n g w h e t h e r t he e f f e c t w as a d d e d
re tur n a d de dIt;
}
/ / S t a r t a n u n d o g ro u p. By u si n g t hi s w i t h an en d Un do Group ( ), yo u
// a l l ow us ers to undo t he w ho le sc r i p t w i th one undo op er at i on.
a p p. b e g i n Un d o Grou p( " App ly Fas t Bl u r to S e l e c t i o n s ") ;
/ / If we d on 't f i n d a ny s e l e c te d l ayer s , p u t u p a n a l e r t a t t h e e n d .
v ar nu m L aye r s Ch an g e d = 0 ;
/ / G e t t he a c t ive com p
v ar a c t iveItem = app.proj ec t. ac t ive Item ;
i f ( a c t ive Item ! = nul l & & ( a c t ive Item i n s t a n ce of Com p Ite m ) ) {
v ar a c t iveCom p = ac t ive Item ;
/ / t r y to a pp ly t o e ve r y se l e c te d layer
v ar sele ctedLayers = ac t ive Comp. se l ec te dL ayers;
for ( v a r i = 0 ; i < s e le c te d L ayer s. l en g th ; i ++ ) {
v ar c u r L aye r = s e l e c te d L ayer s [i ] ;
/ / T h e m e t h o d ret u r n s t r u e i f it a dd s the eff ec t, fa l se oth er w i s e.
i f ( a p p ly Fas t B lu rTo L ayer ( c u r L aye r ) = = t r u e) {
nu m L ayers Ch an g e d+ +;
}
}
}
/ / Pr i n t a m e s s a g e i f n o l ayer s w e re a f f e c te d
if (nu m LayersCh ange d == 0 ) {
a l er t( " P l e as e s e le c t a n AV l ayer o r l ayer s a n d r u n s c r i p t ag ai n " ) ;
}
a pp. e n dUn do Grou p( ) ;
}
Replace text
This script shows the basics for a very useful operation, the automatic editing of text layers. The script looks
for selected text layers that contain the text string blue and changes this string to read monday. The word
can appear anywhere in the selected layer, even as part of another word, and still be changed. For example,
bluejean will read mondayjean after the effect is applied.
This script does the following:
sets a function that replaces all instances of blue with monday;
sets a function that applies the first function to a single layer, looking for all Source Text keyframes where
blue might appear, evaluating and reporting each time whether any text was changed;
sets a single undo group for all changes made by the script;
pops up a warning if no layers were changed, instructing the user how to properly apply the script.
{
/ / T h i s s c r i p t re p l a ce s t ex t i n a l l t h e s e l e c t e d tex t l ayer s .
/ / It f i n ds al l i n st an ces o f t h e word " bl u e " a n d ch an g e s t h e m to " m on d ay "
/ / T h i s f un c t i on t akes the St r in g a n d re pl a ce s f i rst Word w it h s econ d Word .
// It rep e at s, s o i t w i l l re pl a ce al l i n s ta n ce s of fi rs tWord i n t heS t r i n g .
168
Examples
169
// Re tu r n s the chan ge d st r i ng .
f un c t io n rep l aceTex tIn S t r i n g ( the S t r in g , f i rst Wo rd , s econ dWord) {
v ar n ew S t r i n g = t he St r i n g ;
w hi l e ( n e wS t r i n g .i n dex Of (f i r st Wo rd ) ! = - 1 ) {
n e w S t r i n g = n e wS t r i n g .rep la ce ( fi r s tWo rd ,s e con dWord) ;
}
re tur n n ewS t r i n g ;
}
/ / T h i s f u n c t i on a p p l i e s t h e cha n ge to o n e s i n g l e l ayer
f u n c t io n rep l a ce Tex t In L ayer ( t h e L aye r, f i r s t Word , s e con d Word ) {
v ar ch an g ed S om e th i n g = f al s e;
// Ge t t he sou rceText prop er t y, if there is one.
v ar s ource Tex t = t he L ayer.s ource Tex t ;
i f (s ource Text != nul l ) {
i f ( s o u rce Te xt . nu m Ke y s = = 0 ) {
/ / tex tVa lue i s a Tex tD o c u m e n t . Re t r i e ve t h e s t r i n g i n s id e
v ar o l d S t r i n g = s o u rceText .v alu e .tex t;
i f ( o l d S t r i n g . i n d ex O f ( f irs t Word ) ! = - 1 ) {
v ar n e w S t r i n g = rep l a ce Tex tIn S t r i n g ( o l d St r i n g , f i r st Word , s e con d Word ) ;
if (oldString != newString) {
sou rceTex t.s e tVa lue (n e wS t r i n g ) ;
ch an g e dS om e t hi n g = t r ue ;
}
}
} else {
/ / D o i t f o r e a ch ke y fr am e :
for ( v a r ke y In dex = 1 ; ke y In dex < = s o u rce Tex t . nu m Ke y s; ke y In de x+ + ) {
/ / tex tVa lue i s a Tex tD o c u m e n t . Re t r i e ve t h e s t r i n g i n s id e
v ar o l d S t r i n g = s o u rceText .ke y Val u e ( ke y In de x ). tex t ;
i f ( o l d S t r i n g . i n d ex O f ( f irs t Word ) ! = - 1 ) {
v ar n e wS t r i n g = re pl a ce Tex t In St r i n g ( o l d S t r in g , fi r s tWo rd , s e con dWord) ;
if ( o l d S t r i n g ! = n e w S t r in g ) {
so urceTex t. se t Valu eAt Ke y ( ke y In dex ,n ew S t r in g );
cha n g ed S om e thi n g = t r u e;
}
}
}
}
}
/ / Re t u r n a b oo le an s ay i n g w h e t h e r w e rep l a ce d a ny t ex t
re tur n ch an g e dS om e t hi n g ;
}
/ / S t a r t a n u n d o g ro u p. By u si n g t hi s w i t h an en d Un do Group ( ), yo u
// a l l ow us ers to undo t he w ho le sc r i p t w i th one undo op er at i on.
a p p. b e g i n Un d o Grou p( " App ly Tex t C h a n g e to S e l e c t i on s" ) ;
/ / If we d on 't m a ke a ny ch a n g e s , w e ' l l p u t u p a n a l er t a t t h e en d .
v ar nu m L aye r s Ch an g e d = 0 ;
/ / G e t t he a c t ive com p
v ar a c t iveItem = app.proj ec t. ac t ive Item ;
i f ( a c t ive Item ! = nul l & & ( a c t ive Item i n s t a n ce of Com p Ite m ) ) {
169
Examples
170
Next, if the project has been saved at least once before, we set some variables to point to the name of the file
and to the numbering and file extension that we plan to add to it. The l a s t In dex O f () JavaScript function
searches a string backwards (from end to start) and in this case looks for the dot that separates the name from
the extension.
} else {
v ar c u r rF i l e = a p p.p ro je c t . fi l e ;
v ar c u r rF i l e Nam e = c u r r F il e . n a m e;
v ar ext Pos = cu r r F ile Na m e.la st In dexO f(".");
v ar e xt = " " ;
Now we set the c u r r F i l e Na m e variable to the current name, before the dot.
i f (ext Pos ! = - 1 ) {
ext = cu r r F ile Na m e.subst r ing (ext Pos, cur rFileNam e.lengt h);
c u r rF i l e Nam e = c u r r Fi l e Na m e . s u b s t r in g (0 , ex t Po s) ;
170
Examples
171
Next we set a variable that will increment versions starting with 0, and we check to see if there is an underscore
character four characters from the end of c u r rF i l e Nam e . If there is, we assume that the incrementer has run
before, as its job is to assign a 3-digit suffix after an underscore incremented one higher than the last suffix. In
that case we set incrementer to the current numerical string and extract the name without this numerical
extension.
v ar i n c re m e n ter = 0 ;
i f (c u r r F i l e Na m e . ch a r At( c u r r F i l eName. length - 4) = = "_") {
i n c rem e n ter = c u r rF i le Na m e . su b s t r i n g (c u r r F ile Na m e.l en g t h - 3 , c ur rF i l eNam e .l en g th );
c u r rF i l e Nam e = c u r r Fi l e Na m e . s u b s t r in g (0 , c u r rF i l e Nam e . l e n g t h - 4 ) ;
}
Now we add an incrementer loop and test 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.
i n c rem e n ter + +;
v a r i s t r in g = i n c rem e n ter + " " ;
i f ( i n c rem e n te r < 1 0 ) {
i s t r in g = " 0 " + i st r i n g ;
}
i f ( i n c rem e n te r < 1 0 0 ) {
i s t r in g = " 0 " + i st r i n g ;
}
Finally we create a new file using our updated name and extension, display an alert letting the user know the
new file name being saved, and save the project with the new file name.
v ar n e w F i l e = F il e ( c u r r F i l e . p a t h + " / " + c u r rF i le Na m e + " _ " + i s t r i n g + e xt ) ;
a l er t( n ew F i l e.f s Nam e );
a pp. pro je c t .s ave( n e w F i l e ) ;
}
Now we display a prompt to the user asking for what text string we should use.
s e a rch St r i n g = p ro m p t ( " Wha t s t r i n g to ren d e r ? " , s e a rchS t r i n g ) ;
171
Examples
172
We next go through the project looking for the text entered by the user, and check if the item that contains
that text is a composition. We send all compositions with that text string in their names to the render queue.
If the user cancels, the text is undefined. Otherwise, we save the new setting in preferences, converting it to all
lowercase letters for consistency (although the search is not case sensitive).
i f (s e a rch St r i n g ) {
a pp. se t ti n g s .s aveS e t t in g (s ec t i o n Na m e, ke y Nam e , s earchS t r i n g ) ;
s ea rch St r i n g = se archS t r i n g .toL owerCa se () ;
f o r ( i = 1 ; i < = a p p.p ro je c t . num Item s ; + + i ) {
v ar c ur Item = ap p. pro je c t .i tem ( i );
i f ( c u r Ite m i n s t a n c e o f Com pIte m) {
if (cur Item .nam e.to LowerCase(). indexO f(searchSt r i ng) != -1 ) {
a pp. pro je c t .renderQ ueue. items.a dd(cu rItem);
}
}
}
Finally, we make the Render Queue panel visible and bring it to the front, ready for the user to assign save
locations for the new render queue items.
a pp. pro je c t .renderQ ueue. sh ow Wi ndow (t r ue );
}
Next, we make certain that the user entered a new location (and didnt cancel). Then we create a loop for each
selected render queue item. If this item is queued, we take the current render location, give it a new name and
location, and then display an alert stating the new file path.
if (new Loca tion) { //b oo lean to se e if th e user cancel led
for (i = 1 ; i <= app.pro jec t .ren derQ ueue.numItems; ++ i) {
v ar cur Item = app. pro je c t .renderQ ueue. item(i);
i f (c ur Item .st at us == RQItem S t atu s. QUE U E D ) {
f o r ( j = 1 ; j < = c u r Item . num O u t p u t Mo d u l e s ; + + j ) {
v ar c u r O M = c u r Item . o u t pu t Mo dul e ( j ) ;
v ar oldLo c at ion = cu rO M.file;
c u r OM .f il e = n e w F i l e ( n e w Lo c a t i on . to S t r i n g ( ) + " / " + o ld L o c a t i o n . n a m e ) ;
a l er t( c ur OM. fi l e. f sNa m e) ;
}
}
}
}
172
Examples
173
Smart import
This script allows the user to import the full, nested contents of a folder just by selecting it. It attempts to detect
whether each item is a still, moving footage, or an image sequence. The user still has to make other choices in
dialog boxes, such as which layer of a multi-layer image (such as a PSD file) to import.
First, we prompt the user for a folder whose contents are to be imported, and ascertain that the user chooses
a folder rather than cancelling. We then define and call a function to import all of the files, one by one.
v ar t arge tFolder = fo lderGe tD ialo g("Impor t Items from Folder. ..");
/ / re t u r n s a f o l d e r o r nu l l
i f (t a r g e tFo l der ) {
f u n c t io n p ro ce s s F il e (t h e F i l e ) {
v ar i m p o r tO p t i o n s = n e w Im p o r t O p t io n s (t h e F il e );
//create a v ar i able cont aining Im p or t O p t ions
i m p o r tS a feWit hE r ror ( i m p o r t O p t i on s) ;
}
Now we add a function to test whether a given file is part of a sequence. This uses regular expressions, which
are a special type of JavaScript designed to reduce the number of steps required to evaluate a string. The first
one tests for the presence of sequential numbers anywhere in the file name, followed by another making
certain that the sequential files arent of a type that cant be imported as a sequence (moving image files).
We then check adjacent files to see if a sequence exists, stopping after weve evaluated ten files to save
processing time.
f u n c t io n t e s t For S e q u en ce ( f i le s) {
v ar s e a rch er = n e w Re g E x p ( " [ 0 - 9 ] +" ) ;
v ar m ov i e F i l e S e arch e r = n e w Re g Ex p ( " ( m ov| av i| m p g ) $ " , " i " ) ;
v ar p a r s e Re su l t s = n e w Ar r ay ;
for ( x = 0 ; ( x < f ile s. len g th ) & x < 1 0; x + +) {
//te st th at we have a s equ ence, stop pa rsi n g a f ter 10 fi l es
v ar mov i eFileResult = mov i e F ile S earcher.exec(file s[x]. name );
i f (! m ov ie F il e Resu lt ) {
v ar c u r re n t Re su l t = s e a rch er. exe c (f i l e s [x ] . n a m e ) ;
If no match is found using the regular expression looking for a number string, we get null and assume there
is no image sequence. Otherwise, we want an array consisting of the matched string and its location within
the file name.
i f (c ur rentRe sul t ) {
/ / w e h ave a m a tch - t h e s t r i n g con t a i n s num b e r s
/ / t h e m a tch o f t h o s e num b e r s i s s t ore d i n t h e a r r ay [ 1 ]
/ / t a ke t h a t n u m b e r a n d s ave i t i n to p a r s e Re s u lt s
p ar s e Re su l t s[ p ars e Res u l ts .l e n g t h ] = c u r re n tRe su l t [ 0 ] ;
}
e l se {
p ar s e Re su l t s[ p ars e Res u l ts .l e n g t h ] = n u l l ;
}
}
e l se {
p ar s e Re su l t s[ p ars e Res u l ts .l e n g t h ] = n u l l ;
}
173
Examples
174
Now if all of the files just evaluated indicated that they are part of a numbered sequence, we assume that we
have a sequence and return the first file of that sequence. Otherwise, we end this function.
v ar resu l t = nul l ;
for (i = 0 ; i < parseResult s. l ength ; + +i) {
i f (p ars eRe sul t s[ i ]) {
i f (! res u l t) {
resu l t = fi l e s [ i] ;
}
} else {
/ / c a s e i n w hi ch a f i l e n a m e d i d n o t con t a i n a n u m b e r
resu l t = nul l ;
b re a k ;
}
}
re tur n res ul t;
}
Next we add a function to pop up error dialogs if there is a problem with any file we are attempting to import.
f u n c t i o n i m p o r tS a f e Wi t h E r ror ( i m p o r t O p t i o n s ) {
try {
a pp. pro je c t .i m p o r tF i l e ( im p or t O pt i o n s );
} c atch (er ro r ) {
a l er t( e r ror.toS t r i n g ( ) + i m p o r t O p t i on s .f i l e .f s Nam e );
}
}
Next comes a function to actually import any image sequence that we discover using testForSequence(),
above. Note that there is an option for forcing alphabetical order in sequences, which is commented out in the
script as written. If you want to force alphabetical order, un-comment the line importOptions.forceAlphabetical = true by removing the two slashes at the beginning of that line.
f u n c t io n p ro ce s s Fo l d e r (t h e Fo l d e r ) {
v ar f i l es = t heFol der.ge tF i l es () ;
/ / G e t a n a r r ay o f f i l e s i n t h e t a r g e t f o l d e r
//te st w h et her t heFolder conta in s a se quence
v ar s e qu e n ceS t ar tF i l e = tes tFor S e qu e n ce (f i l e s );
//if it doe s cont ain a se quence, impor t t he se quence
i f ( s e q u en ce S t ar tF i l e ) {
v ar i m p o r tO p t i o n s = n e w Im p o r t O p t ion s (s e quen ce S tar t Fi l e) ;
//create a v ar i able cont aining Im p or t O p t ions
i m p or tO p t i ons. se quence = t r ue;
/ / i m p o r t O p t i on s. fo rceA l p h a b e t i c a l = t r u e ;
//un -com m ent this if you want to force alph a order by default
i m p o r tS a feWit hE r ror ( i m p o r t O p t i on s) ;
}
//ot her w i se , impor t th e file s a n d re curse
for ( i n de x i n f i l e s ) {
//Go t hro ug h t he a r r ay, se t ea ch e lement to sing leFile, r un th is:
174
Examples
175
i f (f i l es [i ndex ] i n s ta n ce of F i l e) {
i f (! s e quence St ar tFi l e) {
/ / i f fi l e i s al rea dy p ar t o f a s e qu e n ce , don ' t i m p o r t i t i n d iv id u al ly
pro ce s s Fi l e ( f i le s[ i n de x] ) ;
/ / c al l s the pro ce ss F i l e f un c t ion a b ove
}
}
i f (f i l es [i ndex ] i n s ta n ce of Fol der) {
proces sFol d er (f i l es [in dex ]) ; / / rec u rs i on
}
}
}
proces sFol der (t arge t Fol d er );
}
Now check whether we have email settings already saved in the preferences. If so, we dont need to prompt the
user. If not, run the em ai l _ se tu p. jsx script, which prompts the user for the mail gateway, sender and recipient
addresses. If there are saved settings that you need to change, you can always run the script to make new
settings that overwrite the existing ones.
i f (s a f e To Ru n Sc r i p t) {
v ar s e tt i n g s = ap p.s e tt i n g s ;
175
Examples
176
Now were ready to render. Once rendering is complete, the script creates a text string for the email message
that contains the start time of the render, the render time of each item in the queue, and the total render time.
my Qu eu e.render();
v ar proj ec tNam e = "Unsaved Proj ec t";
i f (a pp. pro j e c t . f i l e ) {
proj ec tNam e = a pp.proje c t.file.na m e;
}
v ar my Me ss age = "Render i ng of " + proje c tName + " i s compl e te .\n\n";
Now email the message, using the three settings from the email_methods.jsx script that has been automatically
run to prompt the user for the server, above.
i f ( ! s e tt i n g s . h aveS e tt i n g ( " E m a i l S e tt i n g s " , " Ma i l S e r ve r " ) | |
! s e tt i n g s . h ave S e tt i n g ( " E m a i l S e tt i n g s " , " Re p ly - to Ad dre s s" ) | |
! s e tt i n g s . h ave S e tt i n g ( " E m a i l S e tt i n g s " , " Re n der Rep o r t Rec i p i en t" ) ){
a l er t( "Can't s end an ema i l, I don't h ave a l l th e s et t i n g s I n ee d. Ab or t i n g . " );
} else {
/ / L oa d co de f rom a fi l e w i th han dy em a i li n g m et ho ds :
v ar e m a il Co de F il e = n e w F i l e ( " e m a i l _ m e t h o d s . j s x " );
em a il Co de F il e .op en ( "r " );
e v a l ( e m a i l Co de F i l e . rea d ( ) ) ;
em a il Co de F il e .cl os e( ) ;
Finally, we send an error if for any reason we are unable to send the mail.
v a r s e r ve r S e tt i n g = se t ti n g s . g e tS e t ti ng ( " E m a i l S e t t in g s " , " Ma i l S e r ve r " ) ;
v ar f ro m S e tt i n g = s et t in g s .g e tS e t t in g (" E m a i l S et t i n g s" , " Repl y - to Ad d re ss " ) ;
v ar to S e t t i n g
176
Examples
177
Email methods
This script creates an email object for use with the previous render-and-email script. It uses code that is
specific to the socket object and therefore requires advanced understanding of networking to edit; the
comments describe its operation.
// Create an ema i l obje ct . T he func t ion m ay be ca lle d b oth
/ / a s a g lo b al f un c t i on a n d a s a con s t r uc tor. It ta kes t he
/ / n a m e o f t h e e m a i l s e r ver, a n d a n o p t i o n a l B o o l e an t h a t ,
/ / i f t r u e , pr i n ts de bu g g in g m e s sa g e s.
/ / T h i s o b j e c t is n o t g u a r a n t e e d to wor k f o r a l l S M T P s e r ve r s ,
/ / s o m e o f t h e m m ay re q u i re a d i f f e re n t s e t o f com m a n d s .
/ / f u n c t io n s :
/ / s e n d ( f rom Ad d re ss , to Ad dre s s, sub je c t, tex t ) - s e n d an e m a i l
// a ut h ( n am e, p as s ) - do a n aut hor iz at ion v i a P OP 3
// bo th fun c t i ons re tur n fa lse on er rors
// sample:
/ / e = n ew E m a il S o cke t (" m a i l .ho s t .com " ) ;
/ / a ut hor i ze v i a PO P 3 (n ot a l l s er vers re qui re auth or i z a t ion )
/ / e . a u t h ( " my n a m e " , " my pa s s " ) ;
/ / s e n d t h e em a i l
/ / e . s e n d ( " m e @ my.com " , " yo u @ yo u . co m " , " My Sub je c t " , " Hi t h e re ! " )
/ / T h i s s c r i p t m a kes u se o f t h e S o cke t o b j e c t , a n d c re a tes a n e w c la s s
/ / c a l l e d E m a i l S o c ket t h a t i s d e r ived f ro m S o cke t. For m o re i n f o r m a t ion o n
/ / c re a t i n g n e w cl a s s e s i n t h i s w ay, con su lt cha p ter 7 of Java Sc r i p t, T he
// D efinit ive Gu id e, by Dav id Flan ag an ( O 'Reil l y) .
/ / T h i s i s t h e con s t r u c tor f o r t h e em a i l s o cke t . It t a ke s a s a r g u m e n t s :
// ser ver - th e a ddress of th e email ser ver (is not che cke d for va lidit y here)
/ / d b g - a b o o l e an , i f t r u e , p r i n t s a d di t i o n al er ror i n for m a t i on
f u n c t i o n E m a i l S o c ke t ( s e r ver, d b g ) {
v ar ob j = n e w S o cke t ;
obj._h ost = ser ver ;
o b j . _ d e b u g = (d b g = = t r u e ) ;
o b j . _ _ p roto _ _ = E m a i lS o cket . p ro to t y p e ;
re tur n o b j;
}
/ / cor re c t t h e p ro toy p e cha in to p o i n t to t h e S o c ke t pro to t y p e cha in
/ / - t hi s i s w ha t a c tua l l y c aus es th e der iv at i on from So cke t.
E m a i l S o cket . p ro to t y p e . __ p ro t o _ _ = S o cke t . p rotot y p e ;
/ / T h i s s e t s u p t h e s e n d ( ) m em b e r f u n c t io n . s e n d ( ) t ake s a s a rg u m en ts :
/ / f ro m - t he e m a il a d d re s s of t he s e n d e r. T hi s i s n o t v a l i d a t e d .
/ / to - t he e m a i l a d d re s s o f t h e re c i p i e n t . If t he re i s a n e r ror,
/ / a n d t h e f ro m a d d re s s i s i n cor re c t, you w i l l n o t b e n o t i f ie d .
// su bje c t - th e content s of th e su bje c t fie l d.
/ / tex t - t he b o dy o f t he m es sa ge .
177
Examples
178
//
// Re tu r n s t r ue if sending succee de d, fa lse oth er w ise (if t here w as an er ror)
//
/ / No te t h a t t h i s cod e u s e s a l o ca l f u n c t i o n o b j ec t to c re ate
/ / t he f un c t i on t ha t i s as si g n ed to s en d .
E m a i l S o cket .p ro to t y p e. sen d = f un c t i on (f rom , to, su b je c t , tex t) {
/ / o p e n t h e s o c ke t o n p o r t 2 5 ( S M T P )
i f (!t h i s . o p e n ( th i s . _ h o st + " : 2 5 " ) )
re tur n f a ls e;
try {
/ / d i sc a rd th e g re e ti n g
v ar g re e t in g = t hi s. re ad ( );
i f (t h i s . _ de bu g )
w r ite ( " R E C V: " + g re e ti n g ) ;
/ / i s s u e E HLO a n d o t h e r com m a n d s
t h i s . _ S M T P ( " E H LO " + f ro m ) ;
t h i s . _ S M T P ( " M AI L F RO M : " + f ro m ) ;
t h i s . _ S M T P ( " RC P T TO : " + to) ;
t h i s . _ S M T P ( " DATA " ) ;
/ / s e n d s u b j e c t a n d t i m e s t am p
t h i s . w r i te l n ( " Fro m : " + f ro m ) ;
t hi s. w r i te l n ( " To: " + to) ;
t hi s. w r i te l n ( " Date: " + n e w Da te( ) .toS t r i n g ( )) ;
if (typeof subject != undefined)
t h i s. w r i te l n ( " Sub j e c t : " + su b j e c t ) ;
t hi s. w r i te l n ( );
/ / s e n d t h e tex t
i f (t y p e o f tex t ! = u n def in ed )
t hi s. w r i te l n ( tex t );
// ter m in ate w i t h a s i ng le dot and w ait f or re sp ons e
t hi s. _ S MT P (" . " );
/ / ter m in ate the se ss i on
this._SMTP ("QUIT");
t hi s. cl o s e( );
re tur n t r ue ;
}
c atch ( e ) {
t hi s. cl o s e( );
re tur n f a ls e;
}
}
// Auth or i ze v ia P OP 3. Supp l y name a n d pa ss word.
// Re tu r n s t r ue if sending succee de d, fa lse oth er w ise (if t here w as an er ror)
/ / Ar g u m e n t s :
/ / n a m e - t he u s e r Nam e o f t he a ccou n t
/ / p as s - t h e pa ss word
E m a i l S o cket . p ro to t y p e . a u t h = f u n c t i on ( n a m e , p a s s ) {
/ / o p e n t h e con n e c ti o n o n p o r t 1 1 0 ( P O P 3 )
178
Examples
179
179
Examples
180
Email setup
This simple script prompts the user for the server name, email sender, and email recipient that are saved as
Settings for the previous render-and-email script. You can run this script as standalone any time you want to
change the settings. The script runs em ai l _ se tu p. js x whenever the settings don't exist; this should happen
only the first time, or if the settings/preferences file is deleted.
This script is a good example of how a script can create settings that are saved in preferences for the sole use
of scripting (as opposed to altering existing After Effects preferences settings).
{
// This script sets up 3 email settings.
/ / It c a n b e r u n a l l by i t s e lf , b u t i t is a l s o c a l l e d
/ / w i t h in " 3 - Re n d e r a n d Mai l . j s x " i f t h e s e t t i n g s a re n ' t ye t s e t .
v ar s e r ve r Val u e = p rom p t ( " E n ter n a m e o f m a i l s e r ve r : " ) ;
v ar f ro m Va lue = pro m p t( " E n ter rep ly - to e m ai l a dd re s s: " );
v ar to Valu e
180
Examples
181
181
Examples
182
File fun
This script shows how to open files, open projects, collect names of the compositions in a scene, prompt a user
for where to write a file, write to a text file, and save the text file. For this example to work correctly, the application preference Allow Scripts to Write Files and Access Network must be set.
/ / F i r s t , c lo se a ny p ro j e c t t h a t m i g h t b e o p e n .
i f (a pp. pro je c t != nul l ){
/ / 3 ch o ices h e re, C l o s e O p t i o n s . D O _ N OT _ S AV E _ C H A N G E S ,
/ / C l o s e O p t i o n s . PRO M P T _ TO _ S AV E _ C H A N G E S , a n d C l o s e O p t i o n s . S AVE _ C H A N G E S
a pp. pro je c t .cl o se( C l os eO p t i on s. D O _ N OT _ S AV E _ C H AN G E S );
}
/ / Pro m p t t h e u s er to p i ck a pro je c t f il e :
/ / F i r st ar g u m e n t is a p ro m p t , s e con d i s t h e f i l e t y p e .
v a r pf i l e = fi l e G e tD i a lo g ( " S e l e c t a p ro j e c t f i l e to o p e n " , " Eg g P a ep " ) ;
i f (p fi l e = = nu l l ) {
a l er t( " No pro je c t fi l e s e le c te d. Ab or t i n g . " );
} else {
/ / O p e n t ha t f i l e . It b ecom e s t he c u r re n t p ro je c t .
v ar my _pro je ct = a pp.op en( pfile );
// Bui l d a def au lt text f il e name from the pro je c t ' s f i l ename .
// Remove t he ".a ep" file ex ten sion (if present), t hen a d d
/ / _ co m p n a m e s . t x t .
v ar de fa ult_tex t_f i l ename ;
v a r su ff i x _ in d ex = pfi l e . n a m e . l a s t In d ex O f( " . a e p " );
i f (su ff i x _ in d ex ! = - 1 ) {
def a u l t_ tex t_ f i l e n a m e = pf i l e . n a m e . su b s t r i n g (0 , su ff i x_ i n d ex );
} else {
def a u l t_ tex t_ f i l e n a m e = pf i l e . n a m e ;
}
def a ult_tex t_f i l ename + = "_compnam es .tx t " ;
/ / Cre a t e a n o th er fi l e o b j e c t for t h e f il e we ' l l w r ite o u t .
/ / F i r s t a r g u m e n t is t h e p ro m p t , s e con d is a d e f a u l t f i l e n a m e , t h i rd i s
// the file type.
v ar tex t_f i l e = f ile PutD i a lo g( "S ele c t a fi le to out p ut you r result s " , def au l t_tex t_f i lena m e, "TEXT tx t") ;
i f ( t ex t _ f i l e = = nul l ) {
a l er t ( " No o u t pu t fi l e s e l e c te d. Ab or t i n g . " );
} else {
/ / o p e n s fi l e f or w r i t i n g . F ir s t a r g um e n t i s m o d e ( " w " f or w r i t i n g ) ,
/ / s e con d a r g u m e n t i s f i l e t y p e ( f o r m ac o n l y) ,
/ / t h i rd a r g u m e n t i s c re a t or (m a c o n l y, " ? ? ? ? " i s n o sp e c i f ic a pp ).
tex t _ f i le . o p e n ( " w" , " T E XT " , " ?? ? ? " ) ;
// Wr ite th e he ading of the file:
tex t_ f i le . w r ite l n ( " He re is a l i s t o f a l l t h e com p s i n " + p f il e .n a m e) ;
tex t_ f i le . w r ite l n ( ) ;
for ( v a r i = 1 ; i <= a p p.p ro j e c t . num Item s ; i + +) {
i f (a pp. pro j e c t . i tem ( i ) i n s ta n ce o f C om pIte m ) {
tex t_ f i l e . w r ite l n ( a p p. pro j e c t . i te m ( i ).n am e ) ;
182
Examples
183
}
}
tex t_ f i le . cl o se ( ) ;
a l er t( " Al l don e !" );
}
}
183
This code dump summarizes all public JavaScript objects (instantiable classes) and enumerated types defined
for After Effects 7.0.
= = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = =
AlphaMo de enum
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A l p h a Mo de .I G N O R E
AlphaMo de .PREMU LT I PLI E D
A l ph a Mo de .S T RA I G H T
= = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = =
App li c a ti o n o b j e c t
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - a c t iva te () n o ret ur n
b e g i n Su ppres s Di a l og s () n o re tur n
b e g i nUndo Group(st r ing u n doName ) no re tur n
b ui l d Na m e : st r i n g : rea d On ly
b u i l d Nu m b e r : i n te g e r : rea d O n l y
c a n ce l Ta s k ( i n t e g e r t a s k I D ) n o re t u r n
e n d Su ppre s s Di a l o g s (b o o le an s h ow A l e r t ) n o re t u r n
e n d Un d o Grou p ( ) n o re t u r n
endWatchFolder() n o re tu r n
e x it Af ter L a u n ch An d Eva l : b o o l e a n : rea d / w r i te
ex it Co de : in te ger : rea d/ w r i te
i s Pro f e s s i o n a l Ver s i o n : b o o l e a n : re a d O n ly
i s Ren d e r E n g i n e : b o o l e a n : rea d O n l y
i s UI Supp re ss ed : b oo l ean : re ad O n ly
is Watch Fo ld er : b oole an : rea d Only
l a n g u a g e : L a n g u a ge : rea d O n l y
n ewPro je c t () n o re tur n
o p e n ( [ F il e fi l e ] ) re tu r n s Pro je c t
pa useWatch Folder(b oo lean do Pause) no re tur n
p ro je c t : Pro j e c t : re ad O n ly
p ur g e(Purg e Tar ge t tar g et ) n o re tu r n
q ui t( ) n o re tu r n
re g is te re d Com p a ny : s t r i n g : rea d O n l y
re g is te re d Nam e : s t r in g : re a dO n l y
s ave Pro je c tO n Cr as h : b o o l e a n : rea d/ w r i te
s che du l eTa sk (s t r i n gTo Exe c ute, fl o a t de l ay, b o ol ea n rep ea t) ret ur n s ta sk ID
s e r i al Num b e r : s t r in g : rea dO n l y
s e tMem or y Us ag eL i m i t s( fl o a t i m a ge Ca che Percent , f l o a t m a xi m u m Me m o r y Pe rcen t ) n o ret u r n
s e tS avePreferen ce sO n Q ui t( b o ol ea n doS ave ) n o re tu r n
s e tt i n g s : S e tt i n g s : re ad O n ly
ver s i o n : s t r i n g : rea d O n l y
184
185
185
186
n a m e : s t r i n g : rea d / w r i te
nu l l L aye r : b o o l e a n : rea d O n l y
nu m Prop er t i e s : i n te g e r : rea d On l y
o u t Po i n t : f l o at : rea d/ w r i te
parent : Layer : re ad/w r ite
p a ren t Pro p e r t y : Pro p e r t y Gro u p : rea d O n l y
preser veTr a n spa rency : b oole an : rea d /w r i te
prop er t y ( i nte g er prop er t y Index) ret ur n s Prop er t yB a se
prop er t y (st r ing proper t y Na me) ret ur n s Prop er t y B a se
prop er t y D ep t h : i n te ger : rea d On ly
prop e r t y Gro u p ([ i n te g e r cou n tUp ]) ret u r n s Prop e r t y Gro u p
prop er t y Ty p e : Prop er t y Ty p e : re ad O n ly
qua l it y : LayerQu alit y : rea d /w r i te
remove() no re tu r n
s e l e c te d : b oo le an : rea d / w r i te
s e l e c t e d Pro p e r t i e s : A r r ay of Pro p e r t y B a s e : rea dO n l y
s et Paren t Wi th Jum p ( L ayer n e wPa ren t ) n o re t ur n
s hy : b oo le an : rea d / w r i te
s o l o : b oo l e an : re ad / w r ite
s ource : AVItem : rea d On ly
s ta r t Ti m e : fl o a t : rea d / w r i te
s t retch : f l o at : rea d/w r i te
t h ree DL ayer : b o o l e a n : rea d / w r i te
t i m e : fl o at : rea d On l y
t i m e Rem ap E n a b l e d : b oo l e a n : re a d / w r it e
t r ac kMat teTy p e : Tr a ck Ma tte Ty p e : rea d/ w r i te
w i dt h : fl o a t : rea d On l y
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Bl e n d in g Mod e e nu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Bl e n d in g Mod e .AD D
Bl e n d in g Mod e .AL PH A _ A DD
Bl e n d in g Mod e .C L A S S I C _ C O LOR _ BUR N
Bl e n d in g Mod e .C L A S S I C _ C O LOR _ D O D G E
Bl e n d in g Mod e .C L A S S I C _ D I F F E R E N C E
Bl e n d in g Mod e .C O LOR
Bl e n d in g Mod e .C O LOR _ BUR N
Bl e n d in g Mod e .C O LOR _ D O D G E
Bl e n d in g Mod e .DA N C I N G _ DI S S OLV E
Bl e n d in g Mod e .DA R K E N
Bl e n d in g Mod e .D I F F E R E N C E
Bl e n d in g Mod e .D I S SO LVE
Bl e n d in g Mod e .E XC LUS I ON
Bl e n d in g Mod e .H A R D _ L I G HT
Bl e n d in g Mod e .H A R D _ M I X
Bl e n d in g Mod e .H UE
Bl e n d in g Mod e .L I G H T E N
Bl e n d in g Mod e .L I N E A R _ BU R N
Bl e n d in g Mod e .L I N E A R _ D O D G E
Bl e n d in g Mod e .L I N E A R _ L I G H T
Bl e n d in g Mod e .LU M I N E S C E N T _ PR E M U L
186
187
Bl e n d in g Mod e .LU M I N O S I T Y
Bl e n d in g Mod e .M ULT I PLY
Bl e n d in g Mod e .N O R M A L
Bl e n d in g Mod e .OV E R L AY
Bl e n d in g Mod e .PI N _ L I G H T
Bl e n d in g Mod e .S AT U RAT I O N
Bl e n d in g Mod e .S C R E E N
Bl e n d in g Mod e .S I L H OU E T E _ AL PH A
Bl e n d in g Mod e .S I L H OU E T T E _ LUM A
Bl e n d in g Mod e .S O F T _ L I G HT
Bl e n d in g Mod e .S T E N C I L _ A L PHA
Bl e n d in g Mod e .S T E N C I L _ LUM A
B l e n d in g Mod e . V I V I D _ L I G H T
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
C a m e r a L ayer o b j e c t ( s u b c l a s s o f L ayer, n o ow n m e t h o d s o r a t t r i b u e s )
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - = == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
C l o s e O p t i o n s e nu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - C l o s e O p t i o n s . D O _ N OT _ S AV E _ C H A N G E S
C l o s e O p t i o n s . PRO M P T _ TO _ S AVE _ C H A N G E S
C l o s e O p t i o n s . SAV E _ C H A N G E S
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
CompItem obje c t (in her it s from Item a n d AV Item, w h ich are no t instan tia ble )
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - a c t iveCamer a : Layer : rea d Only
b g Co lor : Ar r ay of fl o a t : rea d / w r i te
com m e n t : s t r i n g : rea d /w r i te
d i sp layS ta r t Ti me : flo a t : rea d /w r i te
d r a ft 3 d : b o o l e a n : rea d / w r i te
du pl i c ate( ) re tur n s Comp Item
du r at i o n : f l o at : rea d/ w r i te
fo otageMissin g : bo olea n : rea d Only
f r a m e B l e n d i n g : b o o l e a n : rea d/ w r i te
f r a m eD ur a t i on : fl o a t : rea d / w r i te
f r a m eRa te : fl o a t : rea d / w r i te
h as Au di o : b o ol ea n : rea dO n l y
h as Vi de o : b oo l ean : re ad O n ly
h eig h t : i n teg er : re ad / w r i te
h id e S hy L aye r s : b o o l e an : rea d / w r i te
i d : i n te g e r : rea d On l y
l ayer (i n t e g e r l ayer In dex ) re t u r n s L ayer
l ayer (s t r i n g l ayer Na m e ) re t u r n s L ayer
layer (Layer ot herLayer, inte ger re lat iveIn dex) re tur n s Layer
l ayer s : L ayer Co l l e c t i o n : rea dO n l y
mo tionBlu r : bo ole an : rea d /w r i te
n a m e : s t r i n g : rea d / w r i te
nu mLayers : inte ger : rea d Only
parentFolder : Fo lderItem : rea d /w r i te
p i xel As p e c t : f l o at : rea d/ w r i te
preser veNeste d Fr a m eRa te : bo olea n : rea d/w r i te
187
188
188
189
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Fol d e r Ite m o b j ec t ( i n h e r i t s f ro m Ite m , w h i ch i s n o t i n s t a n t ia bl e )
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - com m e n t : s t r i n g : rea d /w r i te
i d : i n te g e r : rea d On l y
i te m ( i n te g e r i te m In d e x ) ret ur n s Ite m
i te m s : Ite m Col l e c t i o n : rea dO n l y
n a m e : s t r i n g : rea d / w r i te
nu mItem s : inte ger : re ad O n ly
parentFolder : Fo lderItem : rea d /w r i te
remove() no re tu r n
s e l e c te d : b oo le an : rea d / w r i te
t y p e Na m e : s t r i n g : rea d O n ly
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Foo ta ge Item o b j e c t ( i n h e r i t s f ro m Ite m , AV Item , and Foot age S ource , w h ich are not inst ant i a ble)
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - com m e n t : s t r i n g : rea d /w r i te
du r at i o n : f l o at : rea dO n l y
f i le : File : rea d Only
fo otageMissin g : bo olea n : rea d Only
f r a m eD ur a t i on : fl o a t : rea d On ly
f r a m eRa te : fl o a t : rea d On l y
h as Au di o : b o ol ea n : rea dO n l y
h as Vi de o : b oo l ean : re ad O n ly
h eig h t : i n teg er : re ad / w r i te
i d : i n te g e r : rea d On l y
ma inSource : Fo ot ageSo urce : re adO n ly
n a m e : s t r i n g : rea d / w r i te
parentFolder : Fo lderItem : rea d /w r i te
p i xel As p e c t : f l o at : rea d/ w r i te
prox ySou rce : Fo ota g eSource : rea d Only
remove() no re tu r n
rep l a ce ( F il e p rox y F il e ) n o re t u r n
replaceWit hP laceho lder( st r ing na me, inte ger w i dth , inte ger he ig ht , flo at fr ameR ate, flo at dur a t i on )
no re tur n
rep l a c e Wi t h S e qu e n c e ( F i l e p rox y F i l e , b o o l e a n f o rce A l p h ab e t i c a l ) n o ret ur n
rep l a ce Wi t h S o l i d (Ar r ay O fF l o a t col o r, s t r i n g n am e , i nteg e r w id t h , i n te g e r h e i g h t, f l o at p i xe lAs p e c tR a t i o )
no re tur n
s e l e c te d : b oo le an : rea d / w r i te
s e t Proxy ( F i l e prox y F i l e ) n o re t u r n
s e t Proxy ToNon e ( ) n o ret u r n
s et Proxy Wi thP l a ceh o l der( s t r in g n am e , i n te g er w id t h, i n teg er h ei g h t, fl o at f r am e R a te, f l o at dur at i o n )
no re tur n
set ProxyWi thSe quence(File prox yFile , bo olea n forceAlphab et i cal) no re tur n
s e t Proxy Wi thS o l id ( Ar r ay O fF l o a t co lor, s t r i n g n a m e , i n te g e r w i d th , i n te g e r h e i g h t ,
f l o at pi xe l Asp ec tR at i o) no ret ur n
t i m e : fl o at : rea d On l y
t y p e Na m e : s t r i n g : rea d O n ly
u s e Prox y : b o o l e a n : rea d / w r i te
u s e dIn : Ar r ay o f Com p Ite m : rea d O n l y
w i dt h : in te ger : rea d/ w r i te
189
190
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Im p o r tAs Ty p e e nu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Im p o r tAs Ty p e .C O M P
Im p o r tAs Ty p e .C O M P _ C RO PPE D _ L AYE R S
Im p o r tAs Ty p e .F O OTAG E
Im p o r tAs Ty p e .P ROJ E C T
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Im por tO p tions ob jec t
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - n ew Im p or t O p t i on s( F i le fi l eToIm p or t ) re tu r n s Im p or tO p t i on s
c an Im p or tAs ( Im p o r t AsTy p e a sTy p e ) ret u r n s b o o l e a n
f i le : File : rea d /w r i te
force A lp h a b e t i c a l : b o o l e a n : rea d/ w r i te
i m p o r tAs : Im p o r t AsTy p e : re ad / w r ite
sequ ence : bo olea n : rea d/w r i te
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Ite m Col l e c t i o n o b j e c t
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - a d dComp ( st r i ng na me, inte ger w i d th , i n te ger he ig ht , f l o at pi xe l Asp ec tR at i o, f l o at dur at i on ,
f l o at fr ameR ate ) re tur n s Comp Item
a d dFol der( s t r in g name ) re tur n s Fol derItem
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Ke y fr am e E as e o b j ec t
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - n e w Ke y fr a m e E as e ( fl o at s p e e d , f l o at i n f lu en ce) ret ur n s Ke y f r a m eE a se
i n f lu e n ce : f l o at : rea d/ w r i te
s p e ed : f l o at : rea d/w r i te
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Ke y fr am eIn ter p o la t i on Ty p e enum
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Ke y fr ameIn ter p o la t ion Ty p e .BE ZIER
Ke y fr am eIn ter p o la t i on Ty p e .H OL D
Ke y fr am eIn ter p o la t i on Ty p e .L I N E A R
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
L a n g u a ge e nu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - L a n g u a ge . E N G L I S H
L a n g u a ge . F R E N C H
L a n g u a ge . G E R M AN
L a n g u a ge . JA PA N E S E
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
L ayer o b je c t ( n o t in s t an t i ab l e , but b a s e cl as s of C am e r a L ayer an d L i g h tL aye r )
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - i n te ger prop er t y Index ) re tur n s Prop er t y Ba s e
s t r i n g pro p e r t y Nam e ) ret u r n s Pro p e r t yB a se
a c t ive : b oo l ean : re ad O n ly
a c t iveAtTim e(f lo at at Ti me ) re tur n s b oole an
a d dProp er t y (s t r i ng prop er t y Name ) re tur n s Prop er t y Ba s e
a pp ly Pre se t( F I l e pres et Na me) no re tur n
can AddProper t y (str ing prop er t y Name ) re tur n s b oole an
190
191
191
192
192
193
193
194
194
195
195
196
196
197
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Proper t y Valu eTy p e enum
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Proper t y Valu eTy p e.CO LO R
Proper t y Valu eTy p e.CU STOM _VALU E
Proper t y Valu eTy p e.LAY E R_IND E X
Proper t y Valu eTy p e.M ARKER
Proper t y Valu eTy p e.M ASK_INDEX
Proper t y Valu eTy p e.NO _VA LUE
Proper t y Valu eTy p e.O n eD
Proper t y Valu eTy p e.SH APE
Proper t y Valu eTy p e.TE XT _D O C UM ENT
Proper t y Valu eTy p e.T hree D
Proper t y Valu eTy p e.T hree D_SPATIAL
Proper t y Valu eTy p e.TwoD
Proper t y Valu eTy p e.TwoD _SPATI AL
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Pul l dow n Ph a s e e nu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Pul l dow n Ph a s e . O F F
Pul l dow n Ph a s e . S S W W W
Pul l dow n Ph a s e . S W W WS
Pul l d ow n Ph a s e . S W W W W _ 2 4 P _ A DVA N C E
Pul l dow n Ph a s e . WS S W W
Pul l d ow n Ph a s e . WS W W W _ 2 4P _ A DVAN C E
Pul l dow n Ph a s e . W WS S W
Pul l d ow n Ph a s e . W WS W W _ 2 4P _ A DVAN C E
Pul l dow n Ph a s e . W W WS S
Pul l dow n Ph a s e . W W WS W _ 2 4 P _ A DVA N C E
Pul l dow n Ph a s e . W W W WS_ 2 4 P _ A DVA N C E
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Pul l dow n Me t h o d e nu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Pul l dow n Me t h o d . A DVAN C E _ 2 4 P
Pul l dow n Me t h o d . P U L L D OW N _ 3 _ 2
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
PurgeTa rge t enu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Pur g e Ta r g e t . A L L _ C AC H E S
Pur g e Ta r g e t . I M AG E _ C AC H E S
PurgeTa rge t. SNAP SH OT _ C AC HES
Purg eTa rg e t. UN D O _C AC HE S
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
RenderQu eu e obj ec t
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - i te m ( i n te g e r i te m In d e x ) ret ur n s Ren d e r Q u e u e It
items : RQ ItemCol l ec t ion : re adO n ly
nu mItem s : inte ger : re ad O n ly
pau se Render ing (b oole an doPa use) no retur n
ren d e r ( ) n o re t u r n
render in g : bo olea n : rea d Only
197
198
198
199
i n Ta n g e n t s : Ar r ay o f f l o a t [ 2 ] : rea d / w r i te
o u t Ta n gen t s : Ar r ay o f f l o a t [ 2 ] : rea d/ w r i te
ver t ices : Ar r ay of f lo a t[ 2] : rea d /w r i te
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
S o l i d S o u rce o b j e c t
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - a l pha Mod e : Al ph aMo de : rea d / w r i te
co lor : Ar r ay of fl o a t : rea d / w r i te
confor mFr a meRate : flo a t : readOn ly
d i s p l ay Fr a m e R ate : f l o at : re a d O n ly
f i e l d S e p a r a t i on Ty p e : F i e l d S e p a r a t i on Ty p e : rea dO n l y
g u e ss A l ph aMo de( ) n o re t u r n
g u e ss Pu l l dow n (Pul l dow n Me t h o d p u l l dow n Me t h o d) n o re t u r n
h a s Al p h a : b o o l e a n : rea dO n l y
h ig hQ ua l it y F ie l dS epa r a ti on : b oo l ean : re ad O n ly
inver t Alpha : bo olea n : rea d /w r i te
i s St i l l : b o o l e a n : rea dO n l y
l o op : i n te g e r : rea d O n ly
na t iveFr am eRa te : flo at : rea d Only
premu l Col or : Ar r ay of f l oa t : re ad / w r ite
rem ovePu l l dow n : Pul l dow n P ha se : re ad O n ly
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Sys tem ob j ec t
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - c a l l Sy s te m ( st r i n g c m d L i n e To Exec tu te ) re t u r n s o u t p u t O f Com m a n d
ma chine Na m e : s t r i ng : rea d Only
o s Nam e : s t r in g : re a d O n ly
os Vers ion : s t r in g : rea dO n ly
us erNam e : s t r i ng : rea dO n ly
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Tex t D o c u m e n t o b j e c t
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - n e w Tex tD o c u m e n t (s t r i n g tex t ) re tur n s Tex tD o c u m e n t
text : s t r i ng : rea d /w r i te
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Tex t L ayer o b j ec t ( s u b cl a s s of AVL ayer, n o ow n m et h o ds o r a t t r i bu t e s )
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - = == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Tim eco de Ba s eTy p e enum
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Tim eco de Ba s eTy p e.AU TO
Tim eco de Ba seTy p e.FPS100
Tim eco de Ba s eTy p e.F P S 24
Tim eco de Ba s eTy p e.F P S 25
Tim eco de Ba s eTy p e.F P S 30
Tim eco de Ba s eTy p e.F P S 48
Tim eco de Ba s eTy p e.F P S 50
Tim eco de Ba s eTy p e.F P S 60
199
200
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Tim e co de Di s p l ay Ty p e e nu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Tim e co de Di s p l ay Ty p e .F E E T _ A N D_ F R A M E S
Tim e co de Di s p l ay Ty p e .F R A M E S
Tim e co de Di s p l ay Ty p e .T I M E C O DE
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Tim eco de F il m Ty p e en um
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Tim eco de F il m Ty p e .MM 16
Tim eco de F il m Ty p e .MM 35
= == == == = == == == = == == == == = == == == == = == == == == = == == == == = == == == == = == == == = == ==
Tr a ck Mat teTy p e enu m
- - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - Tr a ck Mat teTy p e. AL PH A
Tr a ck Mat teTy p e. AL PH A_ I N VE RT E D
Tr a ck Mat teTy p e. LUM A
Tr a ck Ma t teTy p e . LU M A _ I N V E RT E D
Tr a ck Mat teTy p e. N O_ T RAC K _ MAT T E
200
TCP connections are the basic transport layer of the Internet. Every time your Web browser connects to a server
and requests a new page, it opens a TCP connection to handle the request as well as the server's reply. The
JavaScript Socket object lets you connect to any server on the Internet and to exchange data with this server.
The Socket object provides basic functionality to connect to a remote computer over a TCP/IP network or the
Internet. It provides calls like open() and close() to establish or to terminate a connection, or read() or write()
to transfer data. The object also contains a listen() method to establish a simple Internet server; the server uses
the method poll() to check for incoming connections.
Many of these connections are based on simple data exchange of ASCII data, while other protocols, like the
FTP protocol, are more complex and involve binary data. One of the simplest protocols is the HTTP protocol.
The following sample TCP/IP client connects to a WWW server (which listens on port 80); it then sends a very
simple HTTP GET request to obtain the home page of the WWW server, and then it reads the reply, which is
the home page together with a HTTP response header.
rep l y = " " ;
con n = n ew S o cke t;
/ / a cces s Ado b e 's h o m e pa g e
i f ( co n n . o p e n ( " w w w.a do b e .com : 8 0" ) ) {
/ / s e n d a H T T P G E T re q u e st
con n . w r it e ( " GE T / in d ex . h t m l H T T P / 1 . 0 \ n \ n " ) ;
/ / a n d re ad th e s e r ve r ' s rep ly
rep l y = con n .rea d () ;
con n .cl o s e ( ) ;
}
After executing this code, the variable rep ly contains the contents of the Adobe home page together with an
HTTP response header.
Establishing an Internet server is a bit more complicated. A typical server program sits and waits for incoming
connections, which it then processes. Usually, you would not want your application to run in an endless loop,
waiting for any incoming connection request. Therefore, you can ask a Socket object for an incoming
connection by calling the poll() method of a Socket object. This call would just check the incoming connections and then return immediately. If there is a connection request, the call to poll() would return another
Socket object containing the brand new connection. Use this connection object to talk to the calling client;
when finished, close the connection and discard the connection object.
Before a Socket object is able to check for an incoming connection, it must be told to listen on a specific port,
like port 80 for HTTP requests. Do this by calling the listen() method instead of the open() method.
The following example is a very simple Web server. It listens on port 80, waiting until it detects an incoming
request. The HTTP header is discarded, and a dummy HTML page is transmitted to the caller.
con n = n ew S o cke t;
/ / l i s te n o n p o r t 8 0
i f con n .l i s te n ( 8 0 ) ) {
201
202
Often, the remote endpoint terminates the connection after transmitting data. Therefore, there is a connected
property that contains true as long as the connection still exists. If the connected property returns false, the
connection is closed automatically.
On errors, the error property of the Socket object contains a short message describing the type of the error.
The Socket object lets you easily implement software that talks to each other via the Internet. You could, for
example, let two Adobe applications exchange documents and data simply by writing and executing JavaScript
programs.
JavaScript Reference
Socket object constructor
[new ] So cket ();
Socket object.
Properties
conne cted
Boolean
e of
Boolean
er ror
String
A message describing the last error. Setting this value clears any error message.
h ost
String
The name of the remote computer when a connection is established. If the connection is shut down
or does not exist, the property contains the empty string. Read only.
t i m e o ut
Number
202
203
Methods
cl o se
l i ste n
open
Opens a connection.
poll
rea d
rea d l n
w r ite
w r itel n
Terminates the open connection. The return value is true if the connection was closed, false on I/O errors.
Deleting the connection has the same effect. Remember, however, that JavaScript garbage collects the object
at some null time, so the connection may stay open longer than you want to if you do not close it explicitly.
Returns
Boolean
Number
The TCP/IP port number to listen on. Valid port numbers are 1 to 65535. Typical values are 80 for a Web
server, 23 for a Telnet server and so on.
enco din g
String
Optional. The encoding to be used for the connection. Typical values are "ASCII", "binary", or "UTF-8".
Default is ASCII.
Returns
Boolean
Opens the connection for subsequent read/write operations. The call to o p e n ( ) and the call to l i s te n ( ) are
mutually exclusive. Call one function or the other, not both.
203
204
Parameters
h ost
String
The name or IP address of the remote computer, followed by a colon and the port number to connect
to. The port number is required. Valid computer names are, for example, "www.adobe.com:80" or
"192.150.14.12:80".
enco din g
String
Optional. The encoding to be used for the connection. Typical values are "ASCII", "binary", or "UTF-8".
Default is ASCII.
Returns
Checks a listening object for a new incoming connection. If a connection request was detected, the method
returns a new Socket object that wraps the new connection. Use this connection object to communicate with
the remote computer. After use, close the connection and delete the JavaScript object. If no new connection
request was detected, the method returns null.
Returns
Reads up to the specified number of characters from the connection. Returns a string that contains up to the
number of characters that were supposed to be read, or the number of characters read before the connection
closed or timed out.
Parameters
co un t
Number
Optional. The number of characters to read. If not supplied, the connection attempts to read as many
characters it can get until the remote server closes the connection or a timeout occurs.
Returns
String
Reads one line of text up to the next line feed. Line feeds are recognized as CR, LF, CRLF or LFCR pairs.
Returns
String
204
205
Concatenates all arguments into a single string and writes that string to the connection.
Parameters
text
String
Any number of string values. All arguments are concatenated to form the string to be written.
Returns
Concatenates all arguments into a single string, appends a Line Feed character, and writes that string to the
connection.
Parameters
text
String
Any number of string values. All arguments are concatenated to form the string to be written.
Returns
205
206
}
}
f u n c t io n ch a t C li e n t ( ) {
v ar con n e c ti o n = n e w S o c ke t ;
/ / con n e c t to s am pl e s e r ve r
i f ( co n n e c ti o n . o p e n ( " rem o te -pc.cor p.a dob e.com: 123 4")) {
// t hen cha t w i th ser ver
cha t ( co n n e c t i o n ) ;
con n e c t i o n . c l o s e () ;
d e l e te con n e c ti o n ;
}
}
f u n c t io n ch at (c ) {
// select a long timeout
c.t i me out= 10 00;
w hi l e (t r ue ) {
// get one line and echo it
w r iteln (c.rea d());
/ / s top i f t h e con n e c t i o n is b ro ke n
i f ( ! c . con n e c te d )
b re a k ;
/ / rea d a l i n e of tex t
w r ite ( " chat : " ) ;
v ar tex t = re ad l n () ;
i f ( t ex t = = " bye" )
// stop conversat i on if t he user entere d "bye"
b re a k ;
e l se
/ / o t h e r w i se t r a n s m it to s e r ve r
c . w r i te ln (tex t ) ;
}
}
206
A command-line tool provided with After Effects, allows you to render After Effects compositions from the
command line without going through the user interface. This chapter provides reference information for the
tool.
Description
help
re u s e
Reuse the currently running instance of After Effects (if found) to perform the render. When
a running instance is used, a eren der saves preferences to disk when rendering is completed, but does not quit After Effects.
If this argument is not supplied, a eren der launches a new instance of After Effects, even if
one is already running. It quits that instance when rendering is completed, and does not save
preferences.
com p c o m p_ n a m e
If the composition is in the render queue already, and in a queueable state, then the first
queueable instance of that composition in the render queue is rendered.
If the composition is in the project but not in the render queue, then it is added to the render queue and rendered.
If this argument is not provided, a eren der renders the entire render queue as is. In this case,
only the p ro j e c t , l o g , o u t p u t , v, m e m _ u sa ge and cl o s e arguments are
used. All other arguments are ignored.
R Stempla te
r e n d e r _s e t t in g s _ te m p l a t e
207
208
Argument
Description
O Mtemplate
out p ut_mo dul e_te mplate is the name of a template to apply to the output module. If
o u t p u t _ m o d u le _ t e m p l a t e
o u t p u t ou t p ut_p a t h
out p ut_p a t h is a file path or URI specifying the destination render file.
If this argument is not provided, aerender uses the path already in the project file.
s star t_frame
e e n d _ f ra m e
e n d_ f ram e is the last frame to render (note that specified frame is rendered).
If this argument is not provided, aerender uses the end frame in the file.
i i n c re m e n t
m e m _ u sa ge
im a ge_ c ac h e_ p e rce n t specifies the maximum percent of memory used to cache already
rendered images/footage.
m a x _ m e m _ p e rc e n t
m a x _ m e m _ p e rce n t specifies the total percent of memory that can be used by After
Effects.
For both values, if installed RAM is less than a given amount (n gigabytes), the value is a percentage of the installed RAM, and is otherwise a percentage of n. The value of n is: 2 Gb for
Win32, 4 Gb for Win64, 3.5 Gb for Mac OS.
v ve rb os e_flag
c lo s e _ f la g specifies whether or not to close the project when done rendering, and whether
or not to save changes. One of:
s oun d _ f la g specifies whether or not to play a sound when rendering is complete. One of
O N or O F F. Default is OFF.
ve r s i on
Displays the version number of a eren d er to the console. Does not render.
Examples
To render everything in the render queue as is in the project file, enter this command:
a eren d er - pro je c t c :\ proj ec ts \ proj1 .a ep
208
209
209