ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Control the opacity of a comp using a marker in a different comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Stefan Joyce
Control the opacity of a comp using a marker in a different comp
on Jun 6, 2018 at 4:49:13 pm
Last Edited By Stefan Joyce on Jun 6, 2018 at 7:07:48 pm

Hi there!

I have two comps on my timeline, one is called "eyes" the other "pupils".

Within the comp "eyes" I have two markers setup. At frame one I have a marker called "show" and another set further along called "hide".

I'm trying to set the opacity of "pupils" to 100 if the timeline in "eyes" is on the marker "show". Then, when the timeline is on the marker "hide", I would like to the set the opacity of "pupils" to 0.

Many thanks in advance!


Return to posts index

Dan Ebberts
Re: Control the opacity of a comp using a marker in a different comp
on Jun 6, 2018 at 7:18:59 pm

Probably like this:


m = comp("eyes").marker;
val = 100;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0){
if (m.key(n).comment == "hide") val = 0;
}
}
val



Dan



Return to posts index

Stefan Joyce
Re: Control the opacity of a comp using a marker in a different comp
on Jun 6, 2018 at 8:08:12 pm

Hi Dan

Thanks for your quick reply. The expression works but I'm having an issue. The "eyes" comp is time remapped and has toggle hold keyframe applied, so it's being told to go to different sections within the comp. It's as though the "pupils" expression doesn't take into account that the timeline in the "eyes" comp has been placed on hold by the toggle hold keyframe. The expression picks up the "show" marker and sets the opacity to 100, but it's as though the timeline just carries on and the expression then picks up the "hide" marker and sets the opacity to 0.

Cheers
Stefan


Return to posts index


Dan Ebberts
Re: Control the opacity of a comp using a marker in a different comp
on Jun 6, 2018 at 8:50:34 pm

That's definitely trickier. Try it this way:



m = comp("eyes").marker;
t = thisComp.layer("eyes").timeRemap.value;
val = 100;
if (m.numKeys > 0){
n = m.nearestKey(t).index;
if (t < m.key(n).time) n--;
if (n > 0){
if (m.key(n).comment == "hide") val = 0;
}
}
val



Dan



Return to posts index

Stefan Joyce
Re: Control the opacity of a comp using a marker in a different comp
on Jun 6, 2018 at 9:05:43 pm

Dan you're a rockstar, thanks for your time and help. ❤


Return to posts index

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