Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression from animator behaving awkwardly

  • Expression from animator behaving awkwardly

    Posted by Andrei Popa on May 24, 2021 at 8:43 am

    Hi guys.

    I have a layer that calculates an array. It’s final form is something like “[12,11,10,9,8]”. I want to use this in another property with the help of eval(); If I write this in another layer’s sourceText it works as intended.

    var arr = eval(thisComp.layer(2).text.sourceText.valueAtTime(0));
    arr.includes(Math.floor(time))

    If I write this in the expression field of an animator it throws an error: “Cannot read property ‘includes’ of undefined”

    var arr = eval(thisComp.layer(2).text.sourceText.valueAtTime(0));
    arr.includes(textIndex) ? 100 : 0;

    After I edit the second expression, AE starts to say that even in the first layer there is the same error.

    However, even if the expression in the first layer is shown as one that contains an error, it still works, showing true or false depending where I am in the timeline.

    If I edit the first expression again, this second error disappears but the animator expression still does not work.

    Any suggestion or workaround is well received, thank you.

    Andrei Popa replied 4 years, 11 months ago 1 Member · 1 Reply
  • 1 Reply
  • Andrei Popa

    May 24, 2021 at 9:12 am

    The problem seems to be with the eval argument. If I manually write the text instead of the link, it works. If I try to force the link to a string, using var arr = eval(thisComp.layer(2).text.sourceText.valueAtTime(0).toString()); it still does not work.


    LE:

    I used this for the selector to be able to run a few tests:

    var str = thisComp.layer(2).text.sourceText.valueAtTime(0);
    var arr = eval(str);
    typeof(str) == "string" ? 100 : 0;

    I tested the length and typeof() from the str in the first line. They both match to the correct length and

    “string”.


    Finally, I have tested this and the string is correct. I really don’t know what goes wrong…

    var str = thisComp.layer(2).text.sourceText.valueAtTime(0);
    str === "[12,11,10,9,8]" ? 100 : 0;

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