Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Single Random letters using specific letters?

  • Single Random letters using specific letters?

    Posted by Andy Nguyen on July 3, 2012 at 7:21 pm

    i am trying to make each letter in the word ALLEGORY randomize with letters and numbers.I want to restrict the random letters used to the letters in the word ALLEGORY and mix with random numbers.

    i dont have too much experience with expression and don’t really know where to start =P

    Dan Ebberts replied 13 years, 10 months ago 2 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    July 3, 2012 at 8:23 pm

    Is there more to it than that? I mean, say you end up with “Y9GGE517”–is that all you need, a static string?

    Dan

  • Andy Nguyen

    July 4, 2012 at 1:52 am

    Pretty much. trying to do a matrix-y thing with ALLEGORY. it could be A48GL8Y1 or what ever while its running but i generally want to restrict it to the letters in ALLEGORy

    Where no turtle has gone before!

  • Dan Ebberts

    July 4, 2012 at 6:26 am

    >while its running…

    Ah. You haven’t described that part. What is it that you have in mind?

    Dan

  • Andy Nguyen

    July 5, 2012 at 7:42 pm

    So pretty much, the word ALLEGORY will display and then each letter in the word ALLEGORY will cycle through random numbers and only the letters in the word ALLEGORY.

    EXAMPLE:
    the first letter (A) would cycle randomly through the letters, A, L, E, G, O, R, and Y and the numbers 0-9.

    and so on, for the rest of the letters in the word ALLEGORY. and then end with ALLEGORY again? get it now?

    Where no turtle has gone before!

  • Dan Ebberts

    July 5, 2012 at 8:24 pm

    >get it now?

    Probably not. Here’s a source text expression that seems like it does what you’re asking for, but I’m guessing it isn’t what you had in mind:


    choices = "ALEGORY0123456789";
    str = "ALLEGORY";
    tStart = 1;
    tStop = 3;

    if (time > tStart && time < tStop){
    seedRandom(time,true);
    s = "";
    for (i = 0; i < str.length; i++){
    idx = Math.floor(random(choices.length));
    s += choices[idx];
    }
    }else{
    s = str;
    }
    s

    Dan

  • Andy Nguyen

    July 5, 2012 at 10:35 pm

    wow! thanks Dan, it works exactly the way i wanted.

    is there a way to make it loop?

    like after it stops it has like a 1 secon pause and then randomizes again on an infinite loop?

    Where no turtle has gone before!

  • Dan Ebberts

    July 5, 2012 at 11:43 pm

    Like this:


    choices = "ALEGORY0123456789";
    str = "ALLEGORY";
    tStart = 1;
    tStop = 3;
    tStartAgain = 4;

    if ((time > tStart && time < tStop) || time > tStartAgain){
    seedRandom(time,true);
    s = "";
    for (i = 0; i < str.length; i++){
    idx = Math.floor(random(choices.length));
    s += choices[idx];
    }
    }else{
    s = str;
    }
    s

    Dan

  • Andy Nguyen

    July 6, 2012 at 9:31 pm

    freaking sweet! thank you. one last thing… how would i slow down the random cycling of letters and numbers? its running a tad bit too fast.

    Where no turtle has gone before!

  • Dan Ebberts

    July 6, 2012 at 10:49 pm

    One way:


    choices = "ALEGORY0123456789";
    str = "ALLEGORY";
    tStart = 1;
    tStop = 3;
    cps = 10; // characters per second
    tStartAgain = 4;
    if ((time > tStart && time < tStop) || time > tStartAgain){
    seed = Math.floor(time*cps);
    seedRandom(seed,true);
    s = "";
    for (i = 0; i < str.length; i++){
    idx = Math.floor(random(choices.length));
    s += choices[idx];
    }
    }else{
    s = str;
    }
    s

    Dan

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