Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trigger opacity from another layer’s marker

  • Trigger opacity from another layer’s marker

    Posted by Pontus Danielsson on October 23, 2018 at 1:01 pm

    Hi!
    I’m trying to animate the opacity, triggered by another layer. So my layer should fade out when the time indicator hits “Bumper3″‘s marker. This is what I tried but I’ve made something wrong since this only works if I have the marker on the same layer.

    Help anyone?
    /Pontus

    L = thisComp.layer("Bumper3");
    fadeFrames = 15; m = 0; t = time;
    if(marker.numKeys > 0) {
    m = L.marker.nearestKey(time).index;
    tag = L.marker.key(m).comment;
    if (tag== "In") { t = marker.key(m).time - time}
    else if(tag=="Out") {t = time-marker.key(m).time}
    linear(t, 0, framesToTime (fadeFrames), value, 0)
    }
    else {value}

    /Pontus

    Dan Ebberts replied 6 years, 10 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    October 23, 2018 at 1:19 pm

    It looks like you have three instances where you have:

    marker

    instead of:

    L.marker

    Dan

  • Pontus Danielsson

    October 23, 2018 at 1:35 pm

    That’s it!
    Thank you!!
    /Pontus

    /Pontus

  • Ngoc Mai sixomphon

    September 13, 2019 at 3:54 pm

    Hi,

    i know this post ist almost a year old but this expression is the closes to what I need and I’m not a smart person if it comes to expression.
    I intend to do the exact same thing, only that I have 3 Markers on my Layer “(014_DM_GT_IN_OR_2LINES)”. I named my first one “Start” my second “In” and my third “Out”. My goal is to fade on the opacity at “Start” and fade off at “Out”.

    I copied the given expression on a second Layer “(BG Multiply)” and substituted “…(tag== “In”)…” with “…(tag== “Start”).

    It looks good on the first few frames but it suddenly turns off right between my “Start” marker and my “In” Marker. The “In” marker should be completely irrelevant for this expression.

    Could someone help me ?

    L = thisComp.layer("014_DM_GT_IN_OR_2LINES");
    fadeFrames = 1; m = 0; t = time;
    if(L.marker.numKeys > 0) {
    m = L.marker.nearestKey(time).index;
    tag = L.marker.key(m).comment;
    if (tag== "Start") { t = L.marker.key(m).time - time}
    else if(tag=="OUT") {t = time-marker.key(m).time}
    linear(t, 0, framesToTime (fadeFrames), value, 0)
    }
    else {value}

  • Dan Ebberts

    September 13, 2019 at 4:24 pm

    I’d do it like this:


    L = thisComp.layer("014_DM_GT_IN_OR_2LINES");
    fadeFrames = 1;
    val = 0;
    if(L.marker.numKeys > 0) {
    n = L.marker.nearestKey(time).index;
    if (time < L.marker.key(n).time) n--;
    if (n > 0){
    tag = L.marker.key(n).comment;
    t = time - L.marker.key(n).time;
    if (tag == "Start"){
    val = linear(t, 0, framesToTime (fadeFrames), 0, value)
    }else if (tag == "OUT"){
    val = linear(t, 0, framesToTime (fadeFrames), value, 0)
    }
    }
    }
    val

    Dan

  • Dan Ebberts

    September 13, 2019 at 4:50 pm

    That’s not quite right (it’s trickier than I thought because of the IN marker). Try it this way:


    L = thisComp.layer("014_DM_GT_IN_OR_2LINES");
    fadeFrames = 1;
    val = 0;
    if(L.marker.numKeys > 0) {
    n = L.marker.nearestKey(time).index;
    if (time < L.marker.key(n).time) n--;
    if (n > 0){
    tag = L.marker.key(n).comment;
    if (tag == "OUT"){
    t = time - L.marker.key(n).time;
    val = linear(t, 0, framesToTime (fadeFrames), value, 0)
    }else{
    for (i = n; i > 0; i--){
    if (L.marker.key(i).comment == "Start"){
    t = time - L.marker.key(i).time;
    val = linear(t, 0, framesToTime (fadeFrames), 0, value);
    }
    }
    }
    }
    }
    val

    Dan

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