ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Total character in text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ilya Sire
Total character in text
on Jan 25, 2017 at 1:58:52 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


Return to posts index

Emre Anil
Re: Total character in text
on Jan 25, 2017 at 3:11:40 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"?


Return to posts index

Ilya Sire
Re: Total character in text
on Jan 25, 2017 at 3:20:57 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.


Return to posts index


Emre Anil
Re: Total character in text
on Jan 25, 2017 at 4:25:39 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




Return to posts index

Ilya Sire
Re: Total character in text
on Jan 25, 2017 at 5:06:48 pm

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


Return to posts index

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