Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions randomly loop keyframes – change to color

  • randomly loop keyframes – change to color

    Posted by Wouter Sel on September 6, 2012 at 8:43 am

    Hi, i want to randomly loop keyframes using an expression.
    I’ve made 4 hold keyframes in the Change to Color effect of a layer;
    so that’s 4 specific colors (not random) i want to cycle in a random order over time.

    I also want to be able to edit the speed of the color flickering.

    Pre-comping the layer for time-remapping is not really an option,
    since i have 100+ layers in the comp, and they all should flicker randomly between those 4 colors.

    Wouter Sel replied 13 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 6, 2012 at 1:20 pm

    Something like this should pick a random keyframe value every half second:


    period = .5;
    seed = Math.floor((time-inPoint)/period);
    seedRandom(seed,true);
    if (numKeys > 0){
    n = Math.floor(random(numKeys))+1;
    key(n).value;
    }else
    value

    Dan

  • Wouter Sel

    September 6, 2012 at 1:31 pm

    Thanks for the reply Dan, I’ll give it a try!

    meanwhile I’ve found this after some digging, and it works great:

    posterizeTime(12); // value is in fps
    r = Math.ceil(random(0,numKeys));
    valueAtTime(key(r).time)

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