Forum Replies Created

Viewing 1 - 10 of 9,835 posts
  • Dan Ebberts

    January 25, 2022 at 8:06 pm

    if (a = b) sets a to the value of b, so it will always evaluate true. (a == b) tests the value of a against the value of b. It’s possible that they’re not exactly equal. You might be better off testing if they’re within a pixel of each other like this:

    if (Math.abs(a – b) < 1)

  • Dan Ebberts

    January 25, 2022 at 6:08 pm

    Try changing this:

    if (a = b)

    to this:

    if (a == b)

  • Dan Ebberts

    January 24, 2022 at 8:20 pm

    I’m not sure I understand exactly, but maybe a fill color expression like this:

    var a = thisComp.layer("Settings").effect("01")(1);

    var b = thisComp.layer("Settings").effect("02")(1);

    var c = thisComp.layer("Settings").effect("03")(1);

    var d = thisComp.layer("Settings").effect("04")(1);

    if (a == index){

    thisComp.layer("Settings").effect("Color 01")(1);

    }else if (b == index){

    thisComp.layer("Settings").effect("Color 02")(1);

    }else if (c == index){

    thisComp.layer("Settings").effect("Color 03")(1);

    }else if (d == index){

    thisComp.layer("Settings").effect("Color 04")(1);

    }else{

    value;

    }

  • Dan Ebberts

    January 20, 2022 at 4:35 pm

    Like this, I guess:

    function myEase(t,t1,t2,v1,v2){

    if(t <= t1)return v1;

    if(t >= t2)return v2;

    dtEase = t2 - t1;

    dvEase = v2 - v1;

    tEase = (t-t1)/dtEase;

    if(tEase < .5)

    return v1 + (dvEase/2)*Math.exp(10*(2*tEase-1));

    return v1 + dvEase*(1-Math.exp(10*(1-2*tEase))/2);

    }

    Pos0 = thisComp.layer("Start").transform.position;

    Pos1 = thisComp.layer("Position 1").transform.position;

    Pos2 = thisComp.layer("Position 2").transform.position;

    Pos3 = thisComp.layer("Position 3").transform.position;

    moveTime = effect("moveTime")("Slider");

    m = thisComp.marker;

    n = 0;

    if (m.numKeys > 0){

    n = m.nearestKey(time).index;

    if (m.key(n).time > time) n--;

    }

    if (n > 0){

    t1 = m.key(n).time;

    t2 = t1 + moveTime;

    if (m.key(n).comment == "Start"){

    Pos0;

    }else if(m.key(n).comment == "Pos1"){

    myEase(time,t1,t2,Pos0,Pos1);

    }else if(m.key(n).comment == "Pos2"){

    myEase(time,t1,t2,Pos1,Pos2);

    }else if(m.key(n).comment == "Pos3"){

    myEase(time,t1,t2,Pos2,Pos3);

    }else{

    Pos3;

    }

    }else{

    Pos0;

    }

  • Dan Ebberts

    January 20, 2022 at 1:36 pm

    No, that line just applies the regular ease to the range 0-1 as the time goes from t1 to t2. Then, later in the code, ease gets applied again. So there isn’t anything that controls the amount of ease, it just gets applied twice, essentially easing the ease. You could keep doing that, but at that point you might as well use one of the Penner extreme eases like quart, quint, or exponential.

  • Dan Ebberts

    January 19, 2022 at 9:42 pm

    It’s the JavaScript conditional operator. It’s an alternative to if/else that I like to use because you can put it all on one line without having to add brackets:

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

  • Dan Ebberts

    January 19, 2022 at 8:09 pm

    This should work:

    var a = thisComp.layer("Settings").effect("01")(1);

    var b = thisComp.layer("Settings").effect("02")(1);

    var c = thisComp.layer("Settings").effect("03")(1);

    var d = thisComp.layer("Settings").effect("04")(1);

    var e = thisComp.layer("Settings").effect("Visibility")(1);

    a == index || b == index || c == index || d == index || e == 1 ? 100 : 0

  • Dan Ebberts

    January 19, 2022 at 4:17 pm

    Actually, there is a way to double up on the built-in ease() that I forgot about. You can do something like this:

    Pos0 = thisComp.layer("Start").transform.position;

    Pos1 = thisComp.layer("Position 1").transform.position;

    Pos2 = thisComp.layer("Position 2").transform.position;

    Pos3 = thisComp.layer("Position 3").transform.position;

    moveTime = effect("moveTime")("Slider");

    m = thisComp.marker;

    n = 0;

    if (m.numKeys > 0){

    n = m.nearestKey(time).index;

    if (m.key(n).time > time) n--;

    }

    if (n > 0){

    t1 = m.key(n).time;

    t2 = t1 + moveTime;

    t = ease(time,t1,t2,0,1);

    if (m.key(n).comment == "Start"){

    Pos0;

    }else if(m.key(n).comment == "Pos1"){

    ease(t,Pos0,Pos1);

    }else if(m.key(n).comment == "Pos2"){

    ease(t,Pos1,Pos2);

    }else if(m.key(n).comment == "Pos3"){

    ease(t,Pos2,Pos3);

    }else{

    Pos3;

    }

    }else{

    Pos0;

    }

  • Dan Ebberts

    January 19, 2022 at 3:11 pm

    <div>A couple of small changes should keep it at “Start” initially:</div>

    Pos0 = thisComp.layer("Start").transform.position;

    Pos1 = thisComp.layer("Position 1").transform.position;

    Pos2 = thisComp.layer("Position 2").transform.position;

    Pos3 = thisComp.layer("Position 3").transform.position;

    moveTime = effect("moveTime")("Slider");

    m = thisComp.marker;

    n = 0;

    if (m.numKeys > 0){

    n = m.nearestKey(time).index;

    if (m.key(n).time > time) n--;

    }

    if (n > 0){

    t1 = m.key(n).time;

    t2 = t1 + moveTime;

    if (m.key(n).comment == "Start"){

    Pos0;

    }else if(m.key(n).comment == "Pos1"){

    ease(time,t1,t2,Pos0,Pos1);

    }else if(m.key(n).comment == "Pos2"){

    ease(time,t1,t2,Pos1,Pos2);

    }else if(m.key(n).comment == "Pos3"){

    ease(time,t1,t2,Pos2,Pos3);

    }else{

    Pos3;

    }

    }else{

    Pos0;

    }

    As far as easing goes the only control you currently have is the “move time” slider, unless you want to replace AE’s ease() with your own ease function, which wouldn’t be too hard–you could use one of the Penner eases, but you’d have to pick one.

  • Dan Ebberts

    January 17, 2022 at 4:57 pm

    A couple of things–don’t use startTime as a variable name, it’s a reserved word, so use tStart or something similar. Also, the if clause you added at the end doesn’t get entered after the layer’s in point, so it will have no visible effect on anything, and finally with that if clause at the end, your expression doesn’t have an ending value after the layer’s in point, so you probably need to add an else clause. Not sure exactly what you’re trying to do, so I can’t be more specific…

Viewing 1 - 10 of 9,835 posts

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