ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Set Opacity of exactly LAST character only to Zero with expression?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tristan Summers
Set Opacity of exactly LAST character only to Zero with expression?
on Mar 8, 2018 at 8:13:42 pm

Hi
Is there a way to set OPACITY of the last character in a text line?
I do not want to use CUT as I need it to still be there.

I tried that
The God of Ebberts supplied this, but I don't know how to set opacity to 0 instead of cutting it.

cut = 1;
len = thisComp.layer("TEXT SOURCE").text.sourceText.length - cut;
thisComp.layer("TEXT SOURCE").text.sourceText.substr(0,len)

This is in the text source
I can't figure out how to use it in an opacity animator expression selector...

I am using SourceRectAtTime to duplicate a text box and stick the duplicates to the top and bottom of itself.

Because Curved letters go above and below the baseline, SourceRectAtTime will give you different box sizes if there are or are not curves, (or descenders if using lowercase).
So :
"LINE 01"
is bigger than
"LINE X1"

To get around this, I am putting a "|" At the start and end of a different source layer and using that as the source text.
This will make the whole text box always the same size no matter what.

I can kern out the first "|"

But I need to turn off the last"|"

Cutting it is not the right thing

I wonder if length -1 will work...

cut = 1;
len = thisComp.layer("TEXT SOURCE").text.sourceText.length - cut;
thisComp.layer("TEXT SOURCE").text.sourceText.substr(0,len)


Return to posts index

Dan Ebberts
Re: Set Opacity of exactly LAST character only to Zero with expression?
on Mar 8, 2018 at 9:04:42 pm

If you add an opacity animator and an expression selector, set the opacity to zero, and use this Amount expression for the expression selector:

if (textIndex == textTotal) 100 else 0

it should set the opacity of the last character to zero.

Dan



Return to posts index

Tristan Summers
Re: Set Opacity of exactly LAST character only to Zero with expression?
on Mar 9, 2018 at 10:32:31 am

I was thinking textIndex-1 might work but if that works, the check is in the post.
Tip Jar at motionscript deserves more action from everyone!


Return to posts index

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