ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

AE Scripting: Change value of a variable?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kevin Snyder
AE Scripting: Change value of a variable?
on Apr 20, 2020 at 7:24:54 pm

Is it possible to change the value of a variable based on whether or not the property is from an effect? Here's what I'm trying, but I don't get a change in value when selecting an effect property.

var myProp = selectProps.isEffect;
if (myProp == "false") var T = "cat";
else var T = "dog";


Return to posts index

Dan Ebberts
Re: AE Scripting: Change value of a variable?
on Apr 20, 2020 at 8:25:58 pm

When you do this:

var myProp = selectProps.isEffect;

myProp will be a boolean, so then you can do this:

var T = myProp ? "dog" : "cat"

or, closer to the way you were doing it:

if (myProp)
var T = "dog"
else
var T = "cat";

In any case, you don't need to do this:

if (myProp == "false")

you would do this instead:

if (! myProp)

or, if you insist on doing it that way, at least lose the quotes:

if (myProp == false)



Dan



Return to posts index

Kevin Snyder
Re: AE Scripting: Change value of a variable?
on Apr 20, 2020 at 9:04:08 pm

Thanks, Dan.

So I'm using the code below. From my understanding, if the property is from an effect var myText = "dog" and if the selected property isn't from an effect var myText should be "cat"? Is that the correct assumption? For some reason, it always returns as "cat".

var myProp = selectProps.isEffect;
var myText = myProp ? "dog" : "cat";


Return to posts index


Dan Ebberts
Re: AE Scripting: Change value of a variable?
on Apr 20, 2020 at 9:50:07 pm

If the selected property is the effect itself (not if it belongs to an effect) you should get "dog".

Dan



Return to posts index

Kevin Snyder
Re: AE Scripting: Change value of a variable?
on Apr 21, 2020 at 3:47:32 am

Gotcha, that makes sense. Thanks.


Return to posts index

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