Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Blink on to desired opacity

  • Blink on to desired opacity

    Posted by Frank Lamont on May 18, 2021 at 7:39 pm

    Hi,

    I think I got this script from this forum and it works really well for me, but I want to be able to set it’s final opacity to what ever I want, right now it goes to 100%. What needs to be added to this to make that happen?

    blinks = 5; // The number of times to blink while fading in. you can change this and it will recompute for you

    blinkFrames = blinks*2;

    inFrame = Math.round(in_point/this_comp.frame_duration);

    outFrame = Math.round(out_point/this_comp.frame_duration);

    frame = Math.round(time/this_comp.frame_duration);

    if (frame < inFrame + blinkFrames){

    delta = frame – inFrame;

    if (delta % 2 == 0){

    0;

    } else {

    linear(delta,0,blinkFrames,10,110);

    }

    } else if (frame < outFrame – blinkFrames){

    100;

    } else {

    delta = frame – (outFrame – blinkFrames);

    if (delta % 2 != 0){

    0;

    } else {

    linear(delta,0,blinkFrames,100,0);

    }

    }

    Walter Soyka replied 4 years, 12 months ago 2 Members · 3 Replies
  • 3 Replies
  • Walter Soyka

    May 19, 2021 at 7:45 pm

    That’s some old code you’ve got there! It’ll run, but I’ve modernized it a bit below.

    The key thing that you want to change are the references to 100 (and 110). That’s what’s setting the opacity to maximum. I’ve changed that out to “value” here instead, which will allow you to set the property itself right in the timeline panel to what you want its default maximum opacity to be.

    var blinks = 5; // The number of times to blink while fading in. you can change this and it will recompute for you

    var blinkFrames = blinks*2;

    var inFrame = timeToFrames(thisLayer.inPoint);

    var outFrame = timeToFrames(thisLayer.outPoint);

    var currentFrame = timeToFrames(time);

    if (currentFrame < (inFrame + blinkFrames)) {

    var deltaFrame = currentFrame - inFrame;

    if (deltaFrame % 2 == 0) {

    0;

    } else {

    linear(deltaFrame,0,blinkFrames,10,value);

    }

    } else if (currentFrame < (outFrame - blinkFrames)) {

    value;

    } else {

    var deltaFrame = currentFrame - (outFrame - blinkFrames);

    if (deltaFrame % 2 != 0) {

    0;

    } else {

    linear(deltaFrame,0,blinkFrames,value,0);

    }

    }

  • Frank Lamont

    May 19, 2021 at 7:58 pm

    Thanks for updating that for me!

    I do get an error that says:

    delta = frame – inFrame; (Error: Syntax error)

    I can set the Opacity like you said, it just doesn’t blink.

    Thanks,

    Frank

  • Walter Soyka

    May 19, 2021 at 9:10 pm

    The line “delta = frame – inFrame;” looks like the old code — it should work if you copy and paste mine.

    I also had some trouble copying and pasting your code directly. I was thinking that maybe some of the characters were being replaced by typographical equivalents by the COW since it wasn’t wrapped in a preformatted/code block. If you manually retype that line the way it looks, then delete the original line, it should work.

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