0

I've created this slider and counter which works just fine going from 5x down to the W:

current view

The problem is that I need to create a condition that when a number hits .0 it becomes a whole number, so in this case below, it shouldn't be 5.0x but 5x:

problem

Here is my current expression:

effect("Slider Control")("Slider").value.toFixed(1) + "x";

1 Answer 1

0

screengrab

Here's the code:

myval = effect("Slider Control")("Slider");
SourceText = (Math.round(myval * 10))/10 + "x"

It's a really non-intuitive thing, but multiplying the value by 10, then rounding it to the nearest whole number, then dividing by 10 gives you what you need.

Think of it as "how many values after the decimal point do I want?" and count the number of zeroes in the number used.

1
  • That is not intuitive at all! Thanks for explaining it to me :) Sep 2 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.