Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Counter of characters

  • Counter of characters

    Posted by Senior Gabo on July 8, 2017 at 9:59 am

    Hello,
    I am working on a project where I am supposed to create a character counter on the screen. It has to start at 0 and rise exponentially according to the number of characters written in the sentence and the ones after. Instead of counting all the characters by myself I would like to know if there is a way to automatize the process, a code which allows me to count the characters.
    For now I have created a text with an animation of character and another text for the counter. I managed to link the animation with the counter, but it’s only rising up until 100 and not counting the number of characters but the evolution of the animation.
    If you have an idea of what I could do to create this animation, let me know it would be very useful.
    Thanks.

    Senior Gabo replied 9 years ago 2 Members · 7 Replies
  • 7 Replies
  • Liran Tabib

    July 8, 2017 at 1:09 pm

    Hi Senior
    If you connect the to the layer’s Source Text you can use the “length” property which counts the number of letters you have in the Source Text of the text layer.
    It should look something like this:

    thisComp.layer("TextLayer").text.sourceText.length

    Liran Tabib
    https://www.vdodna.com

  • Senior Gabo

    July 8, 2017 at 1:26 pm

    Hi Liran,
    First of all thank you for taking the time to answer my question.
    I just tried the code. Now the counter it’s writing the total number of characters but it doesn’t start from zero it just show the total.
    What I am looking for is the evolution from zero to the total number of characters depending of the text’s length.
    Is there a way to show the counter climb up together with the text appearing on the screen?

  • Liran Tabib

    July 8, 2017 at 1:45 pm

    Hi Senior
    Sure thing!
    I believe multiplying the length with the value of the range selector will give exactly that. (I assume you are using the Range Selector’s Start/End)

    The algorithm (as oppose to code) should be something like this:

    Text.length*startValue/100

    I hope this is clear enough and to the “point”.

    Liran Tabib
    https://www.vdodna.com

  • Senior Gabo

    July 8, 2017 at 4:24 pm

    Hi Liran,
    So I just tried but can’t manage to make it work.
    I am pasting the algorithm but nothing else except an error message… Even though I think I am pasting the algorithm on the good line.

  • Liran Tabib

    July 8, 2017 at 5:10 pm

    Hi Senior

    In algorithm I meant that it’s a general Idea to solve the problem.
    But you can utilize it like this(just name the relevant layers):

    startValue=thisComp.layer("textLayerName").text.animator("AnimatorName").selector("Range Selector 1").start;
    Text=thisComp.layer("textLayerName").text.sourceText;
    Text.length*startValue/100;

    Liran Tabib
    https://www.vdodna.com

  • Senior Gabo

    July 9, 2017 at 10:32 am

    Hi Liran,

    So I tried with your algorithm :
    startValue=thisComp.layer(“textLayerName”).text.animator(“AnimatorName”).selector(“Range Selector 1”).start;
    Text=thisComp.layer(“textLayerName”).text.sourceText;
    Text.length*startValue/100;


    I replaced “textLayerName” by my text layer called TEXTE and “AnimatorName” by my second text layer used as counter TC.
    But it still doesn’t work. I always got an error message. I also tried to replace TEXTE with TC but no change.
    Am I doing something wrong ?

    Thanks for your help.

  • Liran Tabib

    July 9, 2017 at 11:30 am

    Hi Senior
    I believe the error is because the TC is a layer and not a text animator on the Text Layer.
    To make things easy here is a CS6 project file that shows the implementation of the code:

    11512_counter.aep.zip

    Liran Tabib
    https://www.vdodna.com

  • Senior Gabo

    July 9, 2017 at 3:17 pm

    Hi Liran,
    Thank you very much for your help, I tried on my project and after couples of tests it worked!! ☺
    So the main problem was actually because of my after effect’s version which was in french. So I had to change to english version and adapt the algorithm according to my elements and animations.
    I have just one last question : Is it possible to force the counter to show just the simple number (from 0 to 1, 2, 3…) without comma and what come after?

  • Liran Tabib

    July 9, 2017 at 6:21 pm

    Hi Senior
    I like the gesture!

    You can easily round the numbers using the built-in JS Math in AE:
    round-rounds the number. 2.5->3
    ceil– rounds to the closest number from the “top”. 2.5 -> 3
    floor– rounds to the closest number from the “Bottom”. 2.5->2

    change the last line of code to something like this:

    Math.round(Text.length*startValue/100)

    Liran Tabib
    https://www.vdodna.com

  • Senior Gabo

    July 9, 2017 at 7:58 pm

    It is working!!
    Wow it’s gonna help me a lot on my project.
    I really appreciated your help, I am grateful.
    Thank you so much!!

Page 1 of 2

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