Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change the width only in the horizontal direction by slider

  • Change the width only in the horizontal direction by slider

    Posted by Arti Krakow on January 15, 2018 at 7:24 pm

    Hello guys,

    could you help me please with one expression which i can’t figure out?
    I have an animated bar with text in another layer and I would like to change the width of the bar only in the horizontal direction by slider and only between keyframes 3 and 4 (the static part of the animation). For now, the first part of expression works great, but the second part doesn`t, width remains the same until the end of the animation. I’m a newbie in Java, so can you someone help me?

    Thank you in advance

    Arti

    if (numKeys >=6 ) {
    t1 = key(2).time;
    t2 = key(3).time;
    slider = thisComp.layer("Controls").effect("Scale width")("Slider");
    v1 = [value[0], value[1]];
    v2 = [slider, value[1]];
    easeOut(time, t1, t2, v1, v2);
    } else if (numKeys >=6){
    t4 = key(4).time;
    t5 = key(5).time;
    slider = thisComp.layer("Controls").effect("Scale width")("Slider");
    easeIn(time, t4, t5, v1, v2)
    }

    Arti Krakow replied 8 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Matt Volp

    January 23, 2018 at 4:02 am

    Try this (untested):

    slider = thisComp.layer(“Controls”).effect(“Scale width”)(“Slider”);
    t1 = key(2).time;
    t2 = key(3).time;
    t4 = key(4).time;
    t5 = key(5).time;
    v1 = [value[0], value[1]];
    v2 = [slider, value[1]];

    if (numKeys >=6 )
    easeOut(time, t1, t2, v1, v2);
    else
    easeIn(time, t4, t5, v1, v2)

    Matt

  • Arti Krakow

    January 23, 2018 at 4:05 pm

    Hello, thank you for your help, but your expression isn`t work. But today I finally figured out this problem. This script is works great for me.

    Thanks

    AK

    slider = thisComp.layer("Controls").effect("Scale width")("Slider");
    t1 = key(2).time;
    t2 = key(3).time;
    t4 = key(4).time;
    t5 = key(5).time;
    v1 = [value[0], value[1]];
    v2 = [slider, value[1]];
    v3 = [slider, value[1]];
    v4 = [value[1], value[1]];
    if (time < key(4).time) { easeOut(time, t1, t2, v1, v2); } else if (time < key(5).time) { easeIn(time, t4, t5, v3, v4) } else [key(6).time, value[1]];

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