ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Slider can't turn result into a numeric value...

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Joe Richardson
Slider can't turn result into a numeric value...
on Feb 16, 2020 at 12:12:57 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}


Return to posts index

Joe Richardson
Re: Slider can't turn result into a numeric value...
on Feb 16, 2020 at 12:27:30 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


Return to posts index

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