Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to get a slider value to stay to 2 decimal places in a text layer?

  • How to get a slider value to stay to 2 decimal places in a text layer?

    Posted by Dave Martin on October 8, 2012 at 6:33 am

    I’m using sliders to input values for ‘Source text’ in text layers.

    I want to have the text display a value to 2 demimal places: I.E. “1.20” and NOT “1.2”

    Any ideas guys?

    Thanx 🙂

    Dustin Ward replied 12 years, 12 months ago 3 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    October 8, 2012 at 3:10 pm

    Like this:

    thisComp.layer(“other layer”).effect(“Slider Control”)(“Slider”).value.toFixed(2)

    Dan

  • Dave Martin

    October 17, 2012 at 4:55 pm

    Sorry for not getting back sooner Dan…

    But, Thanks… Just what I needed.

  • Dustin Ward

    July 29, 2013 at 7:40 pm

    Thanks for this info,
    How would I get it to show any numbers besides zeros after the decimal? For example: 1.86-9.63 instead of 1.00-9.00

  • Dan Ebberts

    July 29, 2013 at 7:54 pm

    That’s what it does. If the slider is set to 1.6578, the expression should display 1.66. Maybe I’m not understanding the question.

    Dan

  • Dustin Ward

    July 29, 2013 at 10:19 pm

    hmm… yeah, that’s what I thought the expression was as well. When I apply the expression, I only get zeros after the decimal. Maybe I’m just doing something wrong.

  • Dan Ebberts

    July 29, 2013 at 10:26 pm

    I’m assuming the slider value has something other than zeros, is that correct?

  • Dustin Ward

    July 29, 2013 at 10:42 pm

    No, it is only showing zeros after the decimal. Sorry, I should have clarified that.

  • Dan Ebberts

    July 29, 2013 at 10:45 pm

    The text layer is only going to show zeros if the slider is parked on a whole number. Have you tried setting the slider to some other value?

    Dan

  • Dustin Ward

    July 29, 2013 at 10:51 pm

    Ok, I figured it out. When a slider is on a solid it only has zeros after the decimal. If it’s on a text layer it has all the numbers after the decimal.

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