Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions If/else + linear expression with variables

  • If/else + linear expression with variables

    Posted by Aniello Ferrone on September 26, 2019 at 3:59 pm

    Hi guys, I’ll do my best to make it as clear as possible.

    I built a system of 3 text boxes. Whenever the layer value (“Text”. Text.sourceText.length) of one of these is equal to 0 (so there are no characters), each line disappears, and then all the system is always auto-centered.

    Watch this video to understand
    https://www.dropbox.com/s/zahkzuicfe3fxga/If%3Aelse%2Blinear-expression_tex-boxes.mov?dl=0

    As you see at the end of this short video, the three text boxes are linked to a null object where there is a slider control with a linear expression, this one:

    src = effect(“Slider Control 2”)(“Slider”);
    linear(src, 1, 3, -267, 258);

    which can move the whole system in three positions: up, center and down.

    The problem is that the movement the slider has to make to respect the same margins (the red ones) with 1 line of text, 2 lines of text or 3 lines of text, changes each time, depending on how many text boxes are active, because the shift the slider has to do, is different.

    So i would love to see the slider work from position 1 to 3, differently, depending on these variables:
    (I’ll try to write them down in non-expression language)

    If characters of text line 3 > 0 —-> linear (src,1,3,a,a)
    but If characters of text line 3 = 0 —-> linear (src,1,3,b,b)
    but If characters of text line 3 and 2 = 0 —-> linear (src,1,3,c,c)

    Hope This is clear. I think the expression is hard, so thank you so much in advance for your help

    Aniello

    Aniello Ferrone
    Viral Video Editor
    http://www.fanpage.it

    Aniello Ferrone replied 6 years, 7 months ago 1 Member · 1 Reply
  • 1 Reply
  • Aniello Ferrone

    September 30, 2019 at 4:10 pm

    I dit it myself by the way, if you’re interested

    r1 = comp("Rigo 1").layer("Text");
    r2 = comp("Rigo 2").layer("Text");
    r3 = comp("Rigo 3").layer("Text");
    sum = (r1.text.sourceText.length?1:0) + (r2.text.sourceText.length?1:0) + (r3.text.sourceText.length?1:0);
    slider = effect("Slider Control 2")("Slider");

    //effetto quando 2 righe sono piene
    if(sum == 2){
    linear(slider,1,3,640,115);
    }
    else {
    // effetto quando una riga è piena
    if(sum== 1){
    linear(slider,1,3,704,48);
    }
    // effetto quando tutte le righe sono piene
    else linear(slider,1,3,576,181);
    }

    Aniello Ferrone
    Viral Video Editor
    http://www.fanpage.it

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