Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions AE Scripting: Change value of a variable?

  • AE Scripting: Change value of a variable?

  • Kevin Snyder

    April 20, 2020 at 7:24 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";

  • Dan Ebberts

    April 20, 2020 at 8:25 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

  • Kevin Snyder

    April 20, 2020 at 9:04 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";

  • Dan Ebberts

    April 20, 2020 at 9:50 pm

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

    Dan

  • Kevin Snyder

    April 21, 2020 at 3:47 am

    Gotcha, that makes sense. Thanks.

Viewing 1 - 5 of 5 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy