ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Just because I'm curious... Put an expression into a var

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
Just because I'm curious... Put an expression into a var
on Jan 12, 2018 at 8:36:04 am

I realised I sometimes use an expression more than once in quite a few if/else statements. I'm just used to it being bulky, but never thought about putting the repeated expression into a variable.

a = 1;
fad = eval("if (time < (inPoint + outPoint)/2){ease(time,inPoint,inPoint+a,0,100);} else 0;")
if(thisLayer.name == "Station"){
fad;
} else 0;


although this is just for testing purposes, this worked nicely.

but this doesn't

a = 1;

fad = eval("if (time < (inPoint + outPoint)/2){
ease(time,inPoint,inPoint+a,0,100);
} else 0;")

if(thisLayer.name == "Station"){
fad;
} else 0;


I kinda know why it doesn't work, but is there a way to make the second one work?...As it would be nice just to know how to in the future. I've seen a few possible ways that people have put, but I've had no success.


Return to posts index

Andrei Popa
Re: Just because I'm curious... Put an expression into a var
on Jan 12, 2018 at 9:52:51 am

Andrei to the rescue. In order to have a multiline expression between quotes, you need to use triple quotes. This should work:
a = 1;

fad = eval("""if (time < (inPoint + outPoint)/2){
ease(time,inPoint,inPoint+a,0,100);
} else 0;""")

if(thisLayer.name == "Station"){
fad;
} else 0;


Andrei
My Envato portfolio.


Return to posts index

Scott McGee
Re: Just because I'm curious... Put an expression into a var
on Jan 12, 2018 at 10:33:40 am

face and palm have just met.

Thank you


Return to posts index

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