Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions toFixed not working?!

  • toFixed not working?!

    Posted by Paul Roper on July 12, 2011 at 9:37 pm

    Hello

    I have a very simple expression which is proving to be a right pain. I want to have some text display the value of a slider to a fixed number of decimal places. I have an expression slider control on the text layer, and the expression (below) in the source text. If I remove the .toFixed(2) part, it works fine, but with a whole load of decimals. If I add the .toFixed(2), I get the error:

    After Effects warning: Function num.toFixed is undefined
    Expression disabled.

    Error occurred at line 2.
    Comp: ‘02_02_counter’
    Layer: 1 (‘’)
    Property: ‘Source Text’

    I can use any other value perfectly with the .toFixed thing, it’s just as soon as I involve the slider, it falls over. Is the slider outputting a text string or something? It’s certainly not a format that toFixed likes!

    Any suggestions would be MUCH appreciated!

    – Paul

    num=effect("Slider Control")("Slider");
    num.toFixed(2)

    Segun Oyebode replied 11 years, 4 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    July 12, 2011 at 11:17 pm

    Sometimes you have to explicitly specify you want the value of the slider, not the slider object itself. This should fix it:

    num=effect(“Slider Control”)(“Slider”).value;
    num.toFixed(2)

    Dan

  • Paul Roper

    July 13, 2011 at 4:14 pm

    Thank you very much for that simple fix, Dan – it works perfectly!

    I eventually used a workaround – the good old Numbers effect, with its decimal places and leading zeroes options. But I will certainly be using that .value in future.

    – Paul

  • Segun Oyebode

    April 14, 2015 at 9:41 am

    hello mr Dan i need your help on the following expression, is not working on my cs6 , i am trying to rotate 3d sphere object with camera.

    value+lookAt(thisComp.activeCamera.toworld([0,0,0]),position)[0]
    value+lookAt(thisComp.activeCamera.toworld([0,0,0]),position)[1]
    value+lookAt(thisComp.activeCamera.toworld([0,0,0]),position)[2]

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