Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions decode effect based on a Dan Ebberts expression

  • decode effect based on a Dan Ebberts expression

  • ole sturm

    April 30, 2014 at 6:00 am

    Hi all,

    I found the below expression here on CC and it does everything I need with the exception of one thing – currently, the random letters all stop at once to form the specified text string. However, I need it to “decode” from left to right similar to the effect achieved with the “decoder fade in” preset. Is this something that is possible with expressions or do I need to try a different approach?

    Many thanks

    choices = "GTCA";
    str = "THIS IS THE TEXT STRING THAT APPEARS";
    tStart = 0; //time at which the animation starts
    tStop = 3; //time at which the animation stop
    cps = 20; // characters per second
    tStartAgain = 4; //time at which the animation restarts
    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

  • Kevin Camp

    April 30, 2014 at 3:29 pm

    you might try the text preset ‘decoder fade in’.

    if you don’t want the fade in portino, twirl down the text properties to get to text>animator>opacity and either set it to 100% or delete it all together. (note if you remove the opacity change, you may want to use a fixed width/mono space font to prevent character overlap)

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • ole sturm

    April 30, 2014 at 11:17 pm

    Hi Kevin, that’s certainly the effect I want to achieve but it won’t work as the decode effect does not limit the characters being used – I need to limit mine to G, T, C and A.

  • Kevin Camp

    May 1, 2014 at 6:25 pm

    ole, i must apologize for not fully reading your post, where you had clearly stated that you were looking for something similar to that decoder preset that i recommended. (DOH!)

    looking at the expression, i think you just need to combine substrings of the random string and the final string, something like this:

    choices = "GTCA";
    str = "THIS IS THE TEXT STRING THAT APPEARS";
    tStart = 0; //time at which the animation starts
    tStop = 3; //time at which the animation stop
    cps = 20; // characters per second
    tStartAgain = 4; //time at which the animation restarts
    if ((time > tStart && time < tStop) || time > tStartAgain){
    seed = Math.floor(time*cps);
    seedRandom(seed,true);
    s = ""
    sRand = "";
    for (i = 0; i < str.length; i++){
    idx1 = Math.floor(random(choices.length));
    idx2 = Math.floor(linear(time,tStart,tStop,0,1)*str.length);
    sRand += choices[idx1];
    s = str.substr(0,idx2) + sRand.substr(idx2,str.length);
    }
    }else{
    s = str;
    }
    s

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • ole sturm

    May 2, 2014 at 5:46 am

    No problem at all. Just glad you’re able to help out with this. I have to admit, this is now waaaay beyond me and I have absolutely no idea how this is doing it’s magic. Something’s not quite right though – on frame 1 we see the formed sentence, then at frame 2 scrambled text and at frame 3 the “decode” process starts. However, what I’m hoping it would do is showing randomly scrambled letters animating up until the “tStart” at which point the decode process begins and runs until “tSop”. Not sure if that makes sense.

    Anyhow, thanks again for helping out.

  • Kevin Camp

    May 2, 2014 at 9:42 pm

    it sounds like you don’t need it to repeat, so i omitted that part, but this should do it.

    essentially it just uses the original expression until time exceeds the tStart time, then it does the modified expression.

    choices = "GTCA";
    str = "THIS IS THE TEXT STRING THAT APPEARS";
    tStart = 1; //time at which the animation starts
    tStop = 4; //time at which the animation stop
    cps = 20; // characters per second

    if (time < tStart){
    seed = Math.floor(time*cps);
    seedRandom(seed,true);
    s = "";
    for (i = 0; i < str.length; i++){
    idx1 = Math.floor(random(choices.length));
    s += choices[idx1];
    }
    }
    else if (time >= tStart && time < tStop){
    seed = Math.floor(time*cps);
    seedRandom(seed,true);
    s = "";
    sRand = "";
    for (i = 0; i < str.length; i++){
    idx1 = Math.floor(random(choices.length));
    idx2 = Math.floor(linear(time,tStart,tStop,0,1)*str.length);
    sRand += choices[idx1];
    s = str.substr(0,idx2) + sRand.substr(idx2,str.length);
    }
    }else{
    s = str;
    }
    s

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Tom Stanton

    April 8, 2020 at 1:50 am

    dredging this one up from the depths, but does anyone have a way to complete this effect with the characters resolving at random, rather than right to left? I’ve been trying to make it work for a while and it’s currently beyond me.

    Thanks in advance!

    choices = "QAZWSXEDCRFVTGBYHNUJMIKOLP";

    str = "this is my string";

    tStart = 1; //time at which the animation starts

    tStop = 2.4; //time at which the animation stop

    cps = 0; // characters per second

    if (time &lt; tStart){

    seed = Math.floor(time*cps);

    seedRandom(seed,true);

    s = "";

    for (i = 0; i &lt; str.length; i++){

    idx1 = Math.floor(random(choices.length));

    s += choices[idx1];

    }

    }

    else if (time >= tStart && time &lt; tStop){

    seed = Math.floor(time*cps);

    seedRandom(seed,true);

    s = "";

    sRand = "";

    for (i = 0; i &lt; str.length; i++){

    idx1 = Math.floor(random(choices.length));

    idx2 = Math.floor(linear(time,tStart,tStop,0,1)*str.length);

    sRand += choices[idx1];

    s = str.substr(0,idx2) + sRand.substr(idx2,str.length);

    }

    }else{

    s = str;

    }

    s

  • Jorgen Follestad

    May 26, 2020 at 1:53 pm

    This should do the trick ????

    choices = "qwertuaslh";
    str = "this is my string";
    tStart = 1; //time at which the animation starts
    tStop = 2.4; //time at which the animation stop
    seedRandom(index, true);
    charResult = [];
    s = "";

    // assign each characther a random stop time between tStart and tStop
    for(i = 0; i < str.length; i++){
    num = random(tStart, tStop);
    t = Math.round(num * 100) / 100;
    charResult[i] = t;
    }

    if (time < tStop){
    for (i = 0; i < str.length; i++){
    if(str[i] == ' ') {
    s += ' ';
    } else {
    if(time >= charResult[i]){
    s += str[i];
    } else {
    idx1 = Math.floor(random(choices.length));
    s += choices[idx1];
    }
    }
    }
    }else{
    s = str;
    }

    s

Viewing 1 - 8 of 8 posts

Log in to reply.

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