Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression help

  • Posted by Dankelly on June 21, 2005 at 6:52 pm

    hi,

    I need to random 5 or 6 frames from a precomp, wich has different picts for each frame. I applied time remap to it and this expression::

    hold=5 // frames
    f=thisComp.frameDuration;
    q=comp(“Quadros”).numLayers;
    seed=Math.floor(time/f/hold);
    seedRandom(seed, true);
    Math.floor(random(q))*f

    It worked fine, but here

    Dan Ebberts
    replied 19 years, 7 months ago
    2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    June 21, 2005 at 10:29 pm

    I think the problem is that value and valueAtTime give you the pre-expression value of the time remapping property and you need the post-expression value.

    One way to do it would be to loop through the time line at each frame so you can figure out what’s happened in the past. For example, let’s say you have 6 frames (0 through 5) that you want to cycle randomly with no repeats. Let’s say the first one is frame 3. For the next one you’d add a random integer from 1 through 5 to your previous one and do a modulo 6 divide. So, starting with 3, the possible results for your next number would look like this:

    (3+1)%6 = 4
    (3+2)%6 = 5
    (3+3)%6 = 0
    (3+4)%6 = 1
    (3+5)%6 = 2

    Which means that the next random frame will be different than the previous one. Hopefully that makes sense.

    The key is that you loop through the time line so you’re working with post-expression results rather than pre-expression.

    If you get stuck just holler.

    Dan

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