ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

expression breakdown

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dom Brooks
expression breakdown
on May 17, 2018 at 9:31:18 am

Would anyone be kind enough to explain to me how this expression works?

I'm pretty new with expressions but have a laymans understanding.

I'm trying to learn and want to understand why certain lines effect certain parameters.

This is an expression by JR canest that allows a shape layer to retain it's original scale whilst attached to a parent object's scale value.

i understand the first two lines are establishing parameters s being the scale of the object in question and ps establishing the parents scale value

then i get a little lost.

any help would be great

s=[];
ps=parent.transform.scale.value;
for(i=0;i<ps.length;i++){
s[i]=value[i]*100/ps[i];
}
s


Return to posts index

Sam Catt
Re: expression breakdown
on May 17, 2018 at 12:17:25 pm

so without knowing what these are exactly or how they are effecting the object I can't tell you quite the results. But, I can explain whats going on.

so

s = []; //this is setting a variable for s, to be equal to an iterator

ps=parent.transform.scale.value; //this sets this layers parents scale value to ps

for(i=0; i < ps.length; i++){
s[i]=value[i]*100/ps[i];
}

this is a little more complex, but basically "for" is a loop inside javascript. This loop broken down is

for //do loop in situation ( //bracket tells for loop to look inside here for the situation
i=0; // i is a variable, and it equals 0
i < ps.length; // if i is less than ps.length ( the value number for ps )
*remember ps = parent.transform.scale.value; so it just add .length which calls for the number value*
**in full its parent.transform.scale.value.length;**
i++) // i++ means whatever i is, if before situation is still matching then add one to itself //bracket closes the for loop situation

{ //opens the for loop to allow you to apply something to every instance of the for loop
*in the case above if the value was 50, it would do the for loop 50 times until it stops*

s[i]=value[i]*100/ps[i]; //in this case it's saying s[i] ^^ we saw i changes depending on the 'ps.length' and then calcutes it throughout

s //outputs s

so lets make an example for you:

if the value of scale is 2

s=[];
ps=parent.transform.scale.value;

for(i=0;i<ps.length;i++){
s[i]=value[i]*100/ps[i];
}

( loop broken down )

s[0]=value[0]*100/ps[0];
s[1]=value[1]*100/ps[1];
s[2]=value[2]*100/ps[2];

( end loop )

s


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]