FORUMS: list search recent posts

Trying to break text into different lines

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Cabestany
Trying to break text into different lines
on Aug 28, 2015 at 6:59:50 pm

I have a few text layers which need to take their source text from the comp name, it just makes my job easier as I need to replicate the action several times.
One of the texts is too long and doesn't fit in one line so I'm trying to break it automatically using the expression below.
The expression is not returning any errors but it's not breaking the text either.

My guess is that it's missing the bottom part of the expression: "else" and then something
but I have no idea how to instruct the expression to not break the line.

Can anyone help?
Thanks in advance.

t=thisComp.name;

if


(t.length % 6 ==0)
{
t +="\r";
}
;
t;


Return to posts index

Dan Ebberts
Re: Trying to break text into different lines
on Aug 28, 2015 at 7:18:25 pm

Like this maybe:


maxLen = 6;
t = thisComp.name;
if (t.length > maxLen){
t = t.substr(0,maxLen) + "\r" + t.substr(maxLen);
}
t


Dan



Return to posts index

David Cabestany
Re: Trying to break text into different lines
on Aug 28, 2015 at 7:35:54 pm

This one does the trick.

It's kind of reversing the function by specifying a max amount of characters per line; the original expression I was trying to use divided the number of characters and if the result was 0 then it would break the line (or at least that's what I tried). Yours is a much more straightforward solution.

I'm reading now who substr() works, on your website. I never used it before.

Thanks a lot Dan.


Return to posts index

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