Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Flicker opacity expression issue

  • Flicker opacity expression issue

    Posted by Bryan Woods on March 25, 2013 at 4:58 pm

    I have an expression to flicker a layer’s opacity triggered by a marker, written with the help of Dan, and I noticed that it has different results depending on the version of AE. In CS5, this expression works as intended. When it hits a marker, it flickers for 10 frames then stops

    In CS5.5, it does one really quick flicker, then it doesn’t do anything for almost 4.5 seconds, then starts freaking out (see attached screenshot). Any know if something used in this expression has been subtly changed from CS5 to 5.5?

    //Flickers the parameter applied to it for x# of frames triggered by a layer marker

    duration = 10; //# of frames
    n = 0;

    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n--;
    }
    }

    if (n == 0){
    value;
    } else {
    if (timeToFrames(time) < (timeToFrames(marker.key(n).time)+duration)){
    freq = 50; // 10 = 1 cycle per second
    60*(1 - Math.cos(freq*time*Math.PI*2))
    }else{
    value;
    }
    }

    Dan Ebberts replied 13 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    March 25, 2013 at 7:14 pm

    Ah yes, I think I remember this one. As I recall, in CS5.5, for some reason, timeToFrames() gets cast as a string. It think you just need to change one line. There are probably several ways to do it, but this should work:

    if (timeToFrames(time) < (Number(timeToFrames(marker.key(n).time))+duration)){

    The good news is that it appears to be fixed in CS6.

    Dan

  • Bryan Woods

    March 25, 2013 at 8:08 pm

    Ah, thought so. Your solution seems to work for both CS5.5 and CS6, so thank you.

    I’ve never seen Number() used before though. What is that doing that fixes this for CS5.5? Is it just presenting the result within it as a number instead of as a string?

    Thanks again for you help!

  • Dan Ebberts

    March 25, 2013 at 8:38 pm

    > Is it just presenting the result within it as a number instead of as a string?

    Yes. Without that it concatinates the duration to the end of the “string” from timeToFrames() and you end up with a number that’s much larger than it should be.

    Dan

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