Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Java While Loop in AE CS4

  • Java While Loop in AE CS4

    Posted by Dan Seibert on December 29, 2011 at 7:50 pm

    I tend to make things difficult on myself when creating expressions so here’s what I got and correct if I’m just failing.

    I’m trying to change the random seed of a Rough Edges every 5 frames. Rather than go every 5 frames and changing the value, I’m trying to write an expression. I’ve been testing the expression a Numbers effect so I can have a text box that shows me what’s going on. Well I know you can use some Java in AE so I went, “Hey! How about a while loop?” Well… I whipped up this expression and for whatever reason it keeps changing every frame.

    So… what’s not working here?

    if(time = 0){
    x = random()*10;
    v = Math.round(x);
    }else{
    i=2;
    w=valueAtTime(time-1);
    while(i<=4){
    x=valueAtTime(time-i);
    if(x=w){
    fiveframes = false;
    i++;
    }else{
    fiveframes = true;
    i = 5;
    }
    }
    if(fiveframes = true){
    x=random()*10;
    v=Math.round(x);
    }else{
    v=w;
    }
    }
    v;

    You Don’t Say! Media
    Director – Producer – Editor

    MacBook Pro 2009
    Mac OS X 10.6.8
    2.8 Ghz Intel Core 2 Duo
    4 GB 1067 MHz DDR3
    NVIDIA GeForce 9400M (256MB)
    NVIDIA GeForce 9600M GT (512MB)
    Apple Final Cut Studio 3
    Adobe Production Suite CS4

    Dan Seibert replied 14 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Seibert

    December 29, 2011 at 7:53 pm

    Nevermind. I figured what I was doing wrong. I just need to figure out how to return the time on the comp. But still having the same issue.

    You Don’t Say! Media
    Director – Producer – Editor

    MacBook Pro 2009
    Mac OS X 10.6.8
    2.8 Ghz Intel Core 2 Duo
    4 GB 1067 MHz DDR3
    NVIDIA GeForce 9400M (256MB)
    NVIDIA GeForce 9600M GT (512MB)
    Apple Final Cut Studio 3
    Adobe Production Suite CS4

  • Dan Ebberts

    December 29, 2011 at 8:27 pm

    Try this:

    Math.floor(timeToFrames(time)/5)

    Dan

  • Dan Seibert

    December 29, 2011 at 8:50 pm

    Brilliant! Worked like a charm! Expressions and scripting are definitely on my to learn list. Thanks a lot!

    You Don’t Say! Media
    Director – Producer – Editor

    MacBook Pro 2009
    Mac OS X 10.6.8
    2.8 Ghz Intel Core 2 Duo
    4 GB 1067 MHz DDR3
    NVIDIA GeForce 9400M (256MB)
    NVIDIA GeForce 9600M GT (512MB)
    Apple Final Cut Studio 3
    Adobe Production Suite CS4

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