Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Forcing text inside Source Text is acting weird

  • Forcing text inside Source Text is acting weird

    Posted by Kyung Ko on February 18, 2020 at 7:59 pm

    I created a text layer that can output a warning message instead of the actual input when it exceeds the maximum length set by the slider control.
    It does work most of the time but sometimes it flickers or sometimes it doesn’t work at all. Seems like it’s struggling to choose what from the if statement.
    Can anyone have an idea how can I fix it? Thanks!

    maxW = thisComp.layer("ExpCTRL").effect("Max Text Length (px)")("Slider");
    txtW = this.sourceRectAtTime().width;

    if(txtW <= maxW){
    this.text.sourceText;
    }else{
    "You have exceeded \rthe maximum length allowed.";
    }

    Kyung Ko replied 6 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Andrei Popa

    February 19, 2020 at 7:41 am

    Try with this expression:

    maxW = thisComp.layer("ExpCTRL").effect("Max Text Length (px)")("Slider");
    txtW = sourceRectAtTime().width;
    (txtW <= maxW) ? value : "You have exceeded \rthe maximum length allowed."

    You should use “value” when addressing the property value before the expression. Because sometimes I think AE runs the expression again. And with your expression, the second time it runs, this.text.sourceText; is your error text which satisfies the first part of the if. Then, it’s too long again, then it must go with the second part again, etc.
    I hope I was clear enough.

    Andrei
    My Envato portfolio.

  • Kyung Ko

    February 19, 2020 at 2:05 pm

    I got your point and your code works with no issue. Thanks!

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