Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Blinking layers for emphasis

  • Blinking layers for emphasis

    Posted by Alex Mann on October 13, 2011 at 10:56 am

    Hi there,

    I’m working on an e-learning video where, at a certain point during a voiceover track, I wanted a group of about four layers to emphasise themselves by blinking. There are about three points during the voiceover where different layers would blink and because my stomach turned over at the thought of keyframing opacity on/off for about 20 different layers, I decided to turn to expressions.

    I found a great blinking loop (I wish I could say it was mine, but that would be a big lie) which is too complex for me in terms of the formula to make it blink on/off, but it works great.

    blinkSpeed=1;
    lowOpacity=10.0;
    highOpacity=90.0;
    opNormal=(Math.cos(blinkSpeed*time*Math.PI*2)+1)/2;
    linear(opNormal, 0, 1, lowOpacity, highOpacity);

    The way I decided to get the blinking to start/stop was by use of a slider, which I’d keyframe from 0 to 1 at which point the layer(s) would blink. When I wanted the keyframing to stop, I’d simply keyframe the slider value back to 0.

    Because there are three groups of about 5 layers each which need to blink at certain times, I thought I’d try and be clever and control each group by pickwhipping their Opacity to a Null (a different Null per group).

    So the Null Object code now looks like this.

    blinkSpeed=1;
    lowOpacity=10.0;
    highOpacity=100.0;
    sliderValue=effect("Slider Control")("Slider")
    opNormal = (Math.cos(blinkSpeed*time*Math.PI*2)+1)/2;

    if (sliderValue>0){

    linear(opNormal, 0, 1, lowOpacity, highOpacity);

    } else{

    transform.opacity=100.0;

    }

    As you can guess, there is a bit of a jump from when the slider is keyframed back to 0, but it’s not too bad.

    However, I then thought that it would be a great idea if the Null object Slider could be made to serve two purposes

    1) to start the text blinking
    2) to define the number of times in which the layer would blink (and thus also cancel out the need for the third keyframe setting it back to 0)

    And that’s where I’m at now – kind of a bit clueless as to how to make that happen. I’m still working on it and have been for about the past two hours, but if anyone has any ideas or can point me in the right direction it would be appreciated. Sorry about the length of this post, but I always like to describe everything in as much detail as poss 🙂

    PS. Link to the blinking loop – https://video.ucf.edu/knowledge/reference/pdf/adobe/aft6blink.pdf.

    Alex Mann replied 14 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 13, 2011 at 1:47 pm

    This should let you set the number of blinks with the keyframed slider value. You won’t need a keyframe to stop the blilnking.


    blinkSpeed=1;
    lowOpacity=10.0;
    highOpacity=100.0;
    s =effect("Slider Control")("Slider");
    n = 0;
    if (s.numKeys >0){
    n = s.nearestKey(time).index;
    if (s.key(n).time > time) n--;
    }
    if (n > 0){
    dur = Math.round(s.valueAtTime(s.key(n).time))*(1/blinkSpeed);
    t = time - s.key(n).time;
    if (t < dur){
    opNormal = (Math.cos(blinkSpeed*t*Math.PI*2)+1)/2;
    linear(opNormal, lowOpacity, highOpacity);
    }else{
    highOpacity
    }
    }else{
    highOpacity
    }

    Dan

  • Alex Mann

    October 13, 2011 at 2:32 pm

    Wow, Dan, that is awesome….thankyou so much!

    Now I’m going and looking up what the whole nearestKey, key thing is – but that code couldn’t work better, just perfect!

    I love using things like expressions and things to cut corners and speed things up, but it can really become a time sink when you know what you want to do and have a basic theory, but are just looking for the right syntax.

    Many many thanks again 🙂

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