Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Can a layer with a loop control the layers below it?

  • Can a layer with a loop control the layers below it?

    Posted by David Field on January 21, 2013 at 10:30 am

    Hey guys, I’ve got a stack of layers [2->17] that all use the same expression to reference a null layer[1]’s slider control. They use Mod [%] and Divide tricks in combination with index to slide the opacity up and down to fade layers one after the other – every time the null’s slider hits 100 it moves to the next layer

    I have to drop the expression into each one of the footage layers. This is kinda crap, and I’d prefer to let the Null object write the values into each footage layer in some kind of loop. Kind of like (pseudocode):


    for (i=0; i

    Does AE allow this, or do I have to stick with copy and pasting code?

    David Field replied 13 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 21, 2013 at 9:17 pm

    Expressions can’t control other properties (or other layers), only their host property. You could fashion a script to apply the expression to each layer for you, although, with Edit>Copy Expression Only, it’s very easy to apply the same expression to a lot of layers all at once.

    Dan

  • David Field

    January 22, 2013 at 4:47 am

    Ah, bollocks. Also, the music video’s been cancelled too, so it’s even worse. Silver lining in knowing what I can’t do though, so thanks.

    A quick question popped up while I was trying to clean up the code. I get “function inPoint is undefined” when AE interprets the following. Is there some kind of scope issue I haven’t run into yet? I’m pretty sure functions can’t use globals, hence the inputs named to avoid confusion, but I’m stumped on this snippet.


    function inPoint(cR, idx){
    if (cR > ((idx-2) * 100) ){
    return true;
    }else{
    return false;
    }
    }

    //Determines if the layer should be visible and sets the opacity accordingly [extra conditionals removed].
    if ( inPoint(camRate, index) && outPoint(camRate, index) ){
    //some code
    }else{
    fadeAmount = 0;
    }
    fadeAmount

  • Dan Ebberts

    January 22, 2013 at 6:12 am

    My guess is that you can’t use “inPoint” as a function name because it’s already defined as a layer attribute.

    Dan

  • David Field

    January 22, 2013 at 6:20 am

    Right you are – turns out inPoint and outPoint are (case sensitive) reserved words.

    Also functions can reference global variables, so you don’t need to specify arguments like in my example.

    Thanks!

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