Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to get a Blinking Effect using expressions?

  • Jack Cloud

    August 15, 2011 at 6:08 pm

    Oops here’s the link:

    https://gallery.me.com/jackcloud#100155/blink_timeline

    thisComp.layer(thisComp.layer(“Blink”),4).inPoint
    time < blink.inPoint || time > blink.outPoint ? 100 : 0

    I got an error at the end on line one. Didn’t like the .inPoint after the ,4)
    Without the .inPoint it works but only on 1 instance.

    Still trying though

    cheers

  • Dan Ebberts

    August 15, 2011 at 7:14 pm

    This should target the 3rd instance:

    myInstance = 3;
    blink = thisComp.layer(thisComp.layer(“Blink”),myInstance-1);
    time < blink.inPoint || time > blink.outPoint ? 100 : 0

    Dan

  • Jack Cloud

    August 15, 2011 at 7:27 pm

    Hi Dan, thanks so much for your timely replies. This is useful knowledge as well.
    I may have been unclear though. I would like the eyelash to respond to ALL instances of the Blink
    and so far I’ve only been able to get it to one instance (occurrence). I did notice that I can change the number and it would see the Blink above or below BUT reference ALL has not been successful yet.

    I could use index I suppose but then it would reference the other layers that are NOT Blink as well eh?

    cheers

  • Dan Ebberts

    August 15, 2011 at 7:38 pm

    Try this:


    numInstances = 5;
    idx = thisComp.layer("Blink").index;
    gotBlink = false;
    for (i = 0; i < numInstances; i++){
    L = thisComp.layer(idx+i);
    if (time >= L.inPoint && time < L.outPoint) gotBlink = true;
    }
    gotBlink ? 0 : 100

    Dan

  • Jack Cloud

    August 15, 2011 at 7:53 pm

    THAT DID IT!!! Your a rockstar in my book Dan!
    I only wish I understood more clearly this code you’ve written
    I get the 1st 3 variables
    but can I learn about the for statement on motionscripts
    Also the i statement. I don’t see a variable defining it?
    Whatever you did works and works well. All I have to do is change the expression if I add more instances.
    I could probably connect that to a slider and just count out the number of instances, then I can leave the expression alone.
    YOU ROCK did I already say that?!

    This code is quite useful for grabbing a specific number of layers in a comp and doing something with them.

    numInstances = 5;
    idx = thisComp.layer(“Blink”).index;
    gotBlink = false;
    for (i = 0; i < numInstances; i++){
    L = thisComp.layer(idx+i);
    if (time >= L.inPoint && time < L.outPoint) gotBlink = true;
    }
    gotBlink ? 0 : 100

    cheers

  • Dan Ebberts

    August 15, 2011 at 8:12 pm

    The for statement is basic core JavaScript. The i variable is defined in the for statement. In fact in a script I would write it more formally, like this:


    for (var i = 0; i < numInstances; i++){

    This version should automatically count the instances for you:


    blinkName = "Blink";
    idx = thisComp.layer(blinkName).index;
    gotBlink = false;
    while (idx <= thisComp.numLayers){
    L = thisComp.layer(idx);
    if (L.name != blinkName) break;
    if (time >= L.inPoint && time < L.outPoint){
    gotBlink = true;
    break;
    }
    idx++;
    }
    gotBlink ? 0 : 100

    Dan

Page 2 of 2

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