Skip to main content
Participant
Mar 8, 2015 8:50 AM UTC
Answered

how to remove decimal value (.00) from slider control

Please ask me how to remove decimal value (.00) from slider control and add % (if possible) in after effects cs6.

    francoisg32545302Correct answer
    Participant
    Mar 8, 2015 4:17 PM UTC

    I guess you mean to animate text with a slider.

    Add a slider control (expression controls) to your text layer, and then, add this expression into your Source text:

    x=Math.floor(effect("Slider Control")("Slider"));

    x+" %"

    that's all

    18 replies

    Participant
    Jan 14, 2021 2:26 AM UTC

    I resently use this code to create countdown

     

    slider = effect("Slider Control")("Slider");

    sec = Math.round( slider%60);
    min = Math.floor(slider/60);

    function addZero(n) {
    if (n < 10) return "0" + n else return n;
    }

    addZero(min) + ":" + addZero(sec);

    Translate
    Participant
    Jan 14, 2021 3:18 AM UTC

    Change 60 to 59

    Translate
    DavePod
    Participant
    Nov 10, 2020 4:28 PM UTC

    Cleaner way is this, and you can change the number from zero to set decimal places...

    effect("Slider Control")("Slider").value.toFixed(0) + "%"

    Translate
    Community Expert
    Nov 10, 2020 6:47 PM UTC

    If you add an expression to the slider you lose the ability to use the slider in the effects control panel. If you use value.toFixed(0) or Math.round() in the property then the slider will still function in the effects control panel. 

    Translate
    Participant
    Sep 9, 2021 2:31 PM UTC

    You don't lose the ability to use it if you create your expression around "value".

    Translate
    pedrog23895415
    Participant
    Mar 13, 2019 9:07 PM UTC

    I use this and works too:

    x=Math.floor(effect("Slider Control")("Slider"));

    x+" "

    I just delete the %

    Translate
    francoisg32545302Correct answer
    Participant
    Mar 8, 2015 4:17 PM UTC

    I guess you mean to animate text with a slider.

    Add a slider control (expression controls) to your text layer, and then, add this expression into your Source text:

    x=Math.floor(effect("Slider Control")("Slider"));

    x+" %"

    that's all

    Translate
    Community Expert
    Mar 8, 2015 5:49 PM UTC

    If you add this expression to an expression slider it will only return whole numbers.

    math.round(value);

    You will not be able to manually grab the slider control and make adjustments but you will be able to scrub through the values in the expression control and only end up with whole numbers.

    If you want to add a % sign to the slider control you can't do that, but if you want to use the slider to drive a text layer then francoisg32545302 has given you an expression that will work. It will help us a lot if we knew what you were trying to accomplish.

    Translate
    Known Participant
    Sep 5, 2016 9:39 AM UTC

    Rick, you can always write the "Value" before the "math.round", then you can change the digits straight from the effects control.

    something like this:

    value = Math.round(effect("Slider Control")("Slider"))

    Ido.

    Translate
    Andrew Yoole
    Inspiring
    Mar 8, 2015 11:56 AM UTC

    Precompose, then mask it out.

    Translate
    Participant
    May 28, 2019 7:52 PM UTC

    I'm already triggered

    Translate
    Mylenium
    Legend
    Mar 8, 2015 9:45 AM UTC

    You can't.

    Mylenium

    Translate
    Participant
    Aug 17, 2021 3:31 PM UTC

    You absolutely can

    Translate