Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Total character in text

  • Total character in text

    Posted by Ilya Sire on January 25, 2017 at 1:58 pm

    Hi, i have a text wrote “JAPANESE” with text source use :

    c = thisComp.layer(“Null 1”).effect(“Slider”)(“Slider”); // to slide character
    text.sourceText.substr(0,c)

    another text to display character total. it count based on as slider change
    t=thisComp.layer(“JAPANESE”).text.sourceText.length //length doesn’t work

    how to get a total length of t?

    Thanks

    Ilya Sire replied 9 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Emre Anil

    January 25, 2017 at 3:11 pm

    Are you sure that “.length” is the problem?
    Your code seems perfectly working..

    Did you change the slider effect’s name to “Slider” or is it the default “Slider Control”?

  • Ilya Sire

    January 25, 2017 at 3:20 pm

    Yes the code is corrent, my goal to display a character count as slider animate count word “Japanese” to (number slider value / total char).
    it will be 0 to 8 / 8.

    but length wont take the total of text.

  • Emre Anil

    January 25, 2017 at 4:25 pm

    Now I get it.. you want to display as “current/total”

    For the actual text layer, use a text animator for opacity (set to 0) and change range units to “Index”
    Connect “Start” of range animator to your Slider with expression:
    thisComp.layer("Null 1").effect("Slider")("Slider")
    Add this expression to “End” of range animator to set it to the text’s length:
    text.sourceText.length

    For the counter text add the following expression to source text:

    t = thisComp.layer("JAPANESE").text.sourceText.length;
    i = Math.round(thisComp.layer("Null 1").effect("Slider")("Slider"));
    if(i>t){
    i=t;
    i + "/" + t;
    }
    else if (i<0){
    i=0;
    i + "/" + t;
    }
    else
    i + "/" + t

  • Ilya Sire

    January 25, 2017 at 5:06 pm

    That works beautifully, Emre Anil
    Thanks so much for your help!

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