Change text length with expression

Scripting for After Effects

Change text length with expression

Postby ivanparas on 03/21/2016, 12:33 am

I'm looking to either add/subtract characters from text OR truncate/untruncate preexisting text to a desired number of places. Is something like this doable with expressions?
ivanparas
 
Posts: 254
Joined: 01/21/2009, 10:38 pm
Location: Charleston, SC

Re: Change text length with expression

Postby Mylenium on 03/22/2016, 2:35 am

Sure, but you would need to explain in much more detail what you actually want. People could spend all day telling you about .length(), .substr() and other text processing stuff, including convoluted regex, but in the end it may not get you anywhere.

Mylenium
[Pour Mylène, ange sur terre]
----------------------------------------
www.myleniumblog.com
Mylenium
 
Posts: 3263
Joined: 02/1/2009, 11:45 am
Location: Germany
System Specs: Have, I do!

Re: Change text length with expression

Postby ivanparas on 03/22/2016, 11:42 am

Mylenium wrote:Sure, but you would need to explain in much more detail what you actually want. People could spend all day telling you about .length(), .substr() and other text processing stuff, including convoluted regex, but in the end it may not get you anywhere.

Mylenium


I'm creating some general-use graphic elements for and I'm looking to make a random-numbers text layer that can be customized as far as length of the text and speed of randomness. I have the randomness adjustments figured out, I just need to know how to change the length of the text with a slider. I'm looking to either dynamically add/subtract random numbers or just have a long string of numbers that I can change how many are visible.
ivanparas
 
Posts: 254
Joined: 01/21/2009, 10:38 pm
Location: Charleston, SC

Re: Change text length with expression

Postby Mylenium on 03/23/2016, 12:48 am

http://www.motionscript.com/design-guid ... block.html

Simply substitute the random part with your own stuff and tie the columns and rows to a slider. Here's something that might work for you.

Code: Select all
rows = thisComp.Layer("XYZ").effect("Rows")("Slider");
cols = thisComp.Layer("XYZ").effect("Columns")("Slider");
freq = thisComp.Layer("XYZ").effect("Frequency")("Slider");

posterizeTime(freq);
randMin = 0;
randMax = 500;
s = "";

for(i =0; i < rows; i++){
  s += Math.round(random(randMin,randMax)).toString() + "\r";
}
s


Mylenium
[Pour Mylène, ange sur terre]
----------------------------------------
www.myleniumblog.com
Mylenium
 
Posts: 3263
Joined: 02/1/2009, 11:45 am
Location: Germany
System Specs: Have, I do!

Re: Change text length with expression

Postby ivanparas on 03/25/2016, 4:35 pm

This is exactly what I needed. Thanks.
ivanparas
 
Posts: 254
Joined: 01/21/2009, 10:38 pm
Location: Charleston, SC


Return to After Effects Expressions