Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking number of characters to opacity

  • Linking number of characters to opacity

    Posted by Nihad Spahic on October 26, 2021 at 12:18 am

    Hello everyone, this is my first discussion here. Been a huge fan and for almost every problem with an expression, I have managed to find a solution on this forum.

    However, I can’t find the solution to this specific problem.

    For example, I have a text layer and have an expression in it using a global variable in the source text $.mytext = thisLayer.text.sourceText.length and it retrieves a number of characters.

    I would love to connect for example opacity of the other shape by typing in opacity field if ($.mytext < 5) {100} else {0} and every time I change the text and it has more characters than five opacity will go down to zero. It just stops working if I change the text to something else.

    Cheers

    Nihad Spahic replied 4 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 26, 2021 at 12:50 am

    Hacking the global $ object to simulate global variables is a dicey operation at best and is probably doomed to fail if you change/animate the value (because of the stateless way that rendering occurs in AE). It doesn’t seem like you would need to do it in this case anyway–just have your opacity expression reference the length of the text directly.

  • Nihad Spahic

    October 26, 2021 at 5:50 am

    Hey Dan, thank you so much for your answer. Yes, I have noticed that after effects start to act strange when I use global $. I have managed now to reference it directly to text length.

    v = thisComp.layer("Text").text.sourceText.length;
    if (v<5) {100} else {0}

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