Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Driving layer opacity through expressions

  • Driving layer opacity through expressions

    Posted by Bryan Keeling on October 1, 2008 at 6:31 pm

    Can someone point me in the right direction for driving multiple layer opacity (either 0 or 100) through expressions? The idea being that on frame 1 only layer 1 is %100, on frame 2 only layer 2 is %100, on frame 3 only layer 3 is 100 percent.

    Basically cycling opacity down through layers across a frame range, or a whole comp.

    I know it has something to do with setting a layer index against a linear function but I just can’t get my head around it.

    Thanks. You guys rock.

    -bryan

    Bryan Keeling replied 17 years, 7 months ago 3 Members · 8 Replies
  • 8 Replies
  • Eric Sanderson

    October 1, 2008 at 6:53 pm
    if(index == time){
    100
    }else{
    0}

    is it really going to change each frame? instead of linear id start with an if/else statement using the index. for example…(see code)…but that turns them on every second and leaves them on, im no Dan Ebbert so ill need a few min to play around with it if off and on every frame is what you want lol. But maybe this can get you started in the right path.

  • Eric Sanderson

    October 1, 2008 at 6:56 pm

    oops…replace the “==” with “<"

  • Eric Sanderson

    October 1, 2008 at 7:01 pm
    it took a few more min. but here ya go.

    tt = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);

    if(index == tt){
    100
    }else{
    0}

  • Bryan Keeling

    October 1, 2008 at 7:04 pm

    So, I express that directly to the opacity of each layer? It doesn’t actually seem to be working . . . . ?

    -b

  • Bryan Keeling

    October 1, 2008 at 7:18 pm

    Hey thanks!

    Two more quick questions in regards to same:

    What if there is only 9 layers in the comp, which is 90 frames? Is there a way to get it to cycle back to the top of the index when it gets to the last layer?

    Also, it doesn’t start on frame 1, but rather 2. Is there a way to change that?

    Thanks again!

    -bryan

  • Dan Ebberts

    October 1, 2008 at 8:06 pm

    try this:

    idx = timeToFrames(time)%thisComp.numLayers + 1
    if (index == idx) 100 else 0

    Dan

  • Eric Sanderson

    October 1, 2008 at 8:23 pm
    tt = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);
    
    i = index-1
    
    if(i == tt){
    100
    }else{
    0}

    If yours is starting on frame 2 than you have a layer above all of your scripted layers in your timeline. if its an adjustment layer or something that needs to be on top than in your “index” spot put “index – 1”..id make a variable though.

    And for the looping im sure there is a code but the only code i know off the top of my head only loops set keyframes. I would just pre-comp the scripted layers and dup those.

    Only thing i can think of is theres got to be a way to call out the index # plus its multiple of 10 (for 9 layers)…Dan?

  • Bryan Keeling

    October 1, 2008 at 8:40 pm

    this works great. thanks!

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