Adobe 65009963 Scripting Manual page 121

After effects cs4
Table of Contents

Advertisement

JavaScript Reference
m y S h a pe .c l o s e d = f a l s e ;
m y P r o p e r t y . s e t V a l u e ( m y S 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:
va r myP rop er ty = m yL igh t. color;
va r color Valu e = m yP ro pe rty. value At Tim e( 2,t rue );
c o l o r V a l u e [ 0 ] = 0 . 5 * c o l o r V a l u e [0 ];
m y P r o p e r t y . s e t V a l u e A t T i m e ( 4 , c o l o r V a l u e ) ;
Example: Check that a scale calculated by an expression at time 3.5 is the expected value of [10,50]
va r myProper ty = m yL ayer. sca l e;
/ / f a l s e v a l u e o f p r e E x p r e s s i o n m e a n s e v a l u at e t h e e x p r e s s i o n
va r s c aleV alue = myP rop er ty.v alueA tTime (3 .5,f a ls e) ;
i f ( s c a l e V al u e [0 ] = = 1 0 & & s c a l e V a l u e [ 1 ] = = 5 0 ) {
a l ert ("h urra y");
}
e l s e {
a l ert (" oo ps " ) ;
}
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.
m y P r o p e r t y = m y L a y e r .r o t a t i o n ;
m y P r o p e r t y . s e t V a l u e A t T i m e ( 0 , 0 );
m y P r o p e r t y . s e t V a l u e A t T i m e ( 5 , 9 0) ;
m y P r o p e r t y . s e t V a l u e A t T i m e ( 1 0 , 0 ) ;
Example: Change the keyframe values for the first three keyframes of some source text
m y P r o p e r t y = m y T e x t L a y e r . s o u r c e T e xt ;
i f (m y P r o p e r t y . n u m K e y s < 3 ) {
a l ert ("er ror, I th ough t t her e w ere 3 ke yfra mes");
}
e l s e {
myProper ty.set Va lueAt K ey(1, ne w T e x t D o c u m e n t( " k e y n um b e r 1 " ) ) ;
myProper ty.set Va lueAt K ey(2, ne w T e x t D o c u m e n t( " k e y n um b e r 2 " ) ) ;
myProper ty.set Va lueAt K ey(3, ne w T e x t D o c u m e n t( " k e y n um b e r 3 " ) ) ;
}
Example: Set values using the convenience syntax for position, scale, color, or source text
// Th ese tw o a re eq uiva lent . The se co nd fi l l s i n a de fa ul t o f 0 .
m y L a y e r . p o s i t i o n . se tV al u e ([ 2 0 , 3 0 , 0 ] ) ;
m y L a y e r . p o s i t i o n . se tV al u e ([ 2 0 , 3 0 ] ) ;
// Th ese tw o a re eq uiva lent . The se co nd fi l l s i n a de fa ul t o f 1 00.
myLa yer.scale .setV alue ([50 , 50 , 100 ]);
m y L a y e r .s c al e .s e tV al u e ([ 5 0 , 5 0 ]) ;
// Th ese tw o a re eq uiva lent . The se co nd fi l l s i n a de fa ul t o f 1 .0
Property object
121
121

Advertisement

Table of Contents
loading

This manual is also suitable for:

Creative suite 3 after effects

Table of Contents