Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Set Opacity of exactly LAST character only to Zero with expression?

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

    Posted by Tristan Summers on March 8, 2018 at 8:13 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)

    Tomasz Rembek replied 7 years, 6 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    March 8, 2018 at 9:04 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

  • Tristan Summers

    March 9, 2018 at 10:32 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!

  • Tomasz Rembek

    January 30, 2019 at 4:45 pm

    Hi !

    Can you help me whit this expression

    if (textIndex == textTotal) 100 else 0

    Opacity work on last character but i need not on only 1 character but 3last

    Thanks again for your help!

  • Dan Ebberts

    January 30, 2019 at 5:42 pm

    This should work:

    if (textTotal – textIndex < 3) 100 else 0

    Dan

  • Tomasz Rembek

    January 31, 2019 at 9:05 am

    yeah great thanks !

    Tom

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy