ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trigger opacity from another layer's marker

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Pontus Danielsson
Trigger opacity from another layer's marker
on Oct 23, 2018 at 1:01:21 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


Return to posts index

Dan Ebberts
Re: Trigger opacity from another layer's marker
on Oct 23, 2018 at 1:19:20 pm

It looks like you have three instances where you have:

marker

instead of:

L.marker



Dan



Return to posts index

Pontus Danielsson
Re: Trigger opacity from another layer's marker
on Oct 23, 2018 at 1:35:11 pm

That's it!
Thank you!!
/Pontus

/Pontus


Return to posts index


Ngoc Mai Sixomphon
Re: Trigger opacity from another layer's marker
on Sep 13, 2019 at 3:54:37 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}


Return to posts index

Dan Ebberts
Re: Trigger opacity from another layer's marker
on Sep 13, 2019 at 4:24:38 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



Return to posts index

Dan Ebberts
Re: Trigger opacity from another layer's marker
on Sep 13, 2019 at 4:50:05 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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]