Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Todd Kopriva

    February 6, 2013 at 3:30 pm

    This search got me here:
    https://forums.creativecow.net/thread/2/863343#863343

    ———————————————————————————————————
    Todd Kopriva, Adobe Systems Incorporated
    After Effects quality engineering
    After Effects team blog
    ———————————————————————————————————

  • Christopher Johnstone

    February 6, 2013 at 6:09 pm

    So the expression below works beautifully – thank you.
    I am now trying to generate a colour change on the leading zeros.

    The effect I am after is If the leading zero is in the 10, 100, 1000 + column I would like to generate a colour change and if a leading zero is in the 1 column it needs to remain the same.

    To explain a little further in the following strings:

    “00000.0” or “00001.0”
    The first four zeros would be effected by the colour change.
    The fifth 0 would not.

    “00010.0”
    The first three zeros would be the only ones effected by the colour change.

    “00100.0”
    The first two zeros would be the only ones effected by the colour change.

    “10000.0”
    No zeros would be effected by the colour change.

    Hopefully my explanation made sense?

    Let me know if you have any ideas?

    Many thanks – Chris

    num = comp("name").layer("name").effect("name")("Slider");
    numDigits = 6;
    numDec = 1;

    s = "" + Math.floor(num);
    while(s.length < numDigits) s = "0" + s;
    if (numDec > 0) s += "." + num.toFixed(numDec).split(".")[1];
    s

    Christopher Johnstone

  • Dan Ebberts

    February 6, 2013 at 8:11 pm

    If you add a fill color Animatior, set it to your leading zero color, add an Expression Selector, delete the Range Selector, and add this experssion to the Amount property of the Expression Selector, I think it will do what you want:


    s = text.sourceText;
    r = 100;
    for (i = 1; i <= textIndex; i++){ if (s[i-1] != "0"){ r = 0; break; } } r

    Dan

  • Dan Ebberts

    February 6, 2013 at 8:19 pm

    Oops. Thank doesn’t quite do it. I didn’t read your question close enough. Be back in a bit…

    Dan

  • Dan Ebberts

    February 6, 2013 at 8:28 pm

    If you always have five digits to the left of the decimal, I think this will work:


    if (textIndex > 4) {
    0
    }else{
    s = text.sourceText;
    r = 100;
    for (i = 1; i <= textIndex; i++){
    if (s[i-1] != "0"){
    r = 0;
    break;
    }
    }
    r
    }

    Dan

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