Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Slider can’t turn result into a numeric value…

  • Slider can’t turn result into a numeric value…

    Posted by Joe Richardson on February 16, 2020 at 12:12 pm

    AE: 2020 in new JS Engine:

    I connected a slider to a text whose output is retrieved from a JS file and updated every frame. The problem is, once the JS data runs out, the Text value is “”, but the Slider i connected to it says that it couldn’t turn the (NaN) value into a numeric value. The text layer has a try-catch on it too, but since it’s a text layer, it doesn’t output any error if a number isn’t involved.

    So I added this code, which gets rid of it, but only after clicking on the expression error

    try {parseFloat(text.sourceText)}
    catch (err) {0}

    Joe Richardson replied 6 years, 2 months ago 1 Member · 1 Reply
  • 1 Reply
  • Joe Richardson

    February 16, 2020 at 12:27 pm

    I did more digging and found the reason: the value it tries to parse has to get checked to see if it’s a number right away.

    I started looking for how to write an “if” statement to do this and found a post by Dan Ebberts on here showing it:

    Sorry for wasting forum space =/

    n = parseFloat(yourText);
    if (isNaN(n)) n = value;
    n

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