FORUMS: list search recent posts

Counter of characters

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Senior Gabo
Counter of characters
on Jul 8, 2017 at 9:59:31 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.


Return to posts index

Liran Tabib
Re: Counter of characters
on Jul 8, 2017 at 1:09:31 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
http://www.vdodna.com


Return to posts index

Senior Gabo
Re: Counter of characters
on Jul 8, 2017 at 1:26:25 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?


Return to posts index


Liran Tabib
Re: Counter of characters
on Jul 8, 2017 at 1:45:52 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
http://www.vdodna.com


Return to posts index

Senior Gabo
Re: Counter of characters
on Jul 8, 2017 at 4:24:52 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.



Return to posts index

Liran Tabib
Re: Counter of characters
on Jul 8, 2017 at 5:10:17 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
http://www.vdodna.com


Return to posts index


Senior Gabo
Re: Counter of characters
on Jul 9, 2017 at 10:32:17 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.


Return to posts index

Liran Tabib
Re: Counter of characters
on Jul 9, 2017 at 11:30:47 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
http://www.vdodna.com


Return to posts index

Senior Gabo
Re: Counter of characters
on Jul 9, 2017 at 3:17:28 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?


Return to posts index


Liran Tabib
Re: Counter of characters
on Jul 9, 2017 at 6:21:23 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
http://www.vdodna.com


Return to posts index

Senior Gabo
Re: Counter of characters
on Jul 9, 2017 at 7:58:29 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!!


Return to posts index

Senior Gabo
Re: Counter of characters
on Jul 12, 2017 at 11:21:31 am

Hi Liran,
I have one more question about the animation I'm doing.
So now I have my counter and my text appearing. When the text appears, the counter starts from 0 to the total of characters.
Question : Do you think it's possible to choose the counter's start ? For the first text I need the counter starts from 0, but for the next text I would like the counter start from the last total and so on.
Is it possible ?
Thanks


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]