Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › get number from another comp into Dan’s Universal Counter

  • get number from another comp into Dan’s Universal Counter

    Posted by Bas V breugel on March 13, 2018 at 1:50 pm

    Hi guys,

    I am trying to make this automated ranking system.

    I have 1 comp named ‘CHANGE_TEXT’ where I can input names and scores.

    Inside another comp I have a Textfield with follwing code on the source text. I have animated it with drop in by character.
    comp("CHANGE_TEXT").layer("01_firstname").text.sourceText

    For the score I have used Dan’s Universal code
    numDecimals = 0;
    commas = true
    dollarSign = false;
    beginCount = 0;
    endCount = 250;
    dur = 1.5;

    t = time - inPoint;
    s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

    prefix = "";
    if (s[0] == "-"){
    prefix = "-";
    s = s.substr(1);
    }
    if(dollarSign) prefix += "$";

    if (commas){
    decimals = "";
    if (numDecimals > 0){
    decimals = s.substr(-(numDecimals + 1));
    s = s.substr(0,s.length - (numDecimals + 1));
    }
    outStr = s.substr(-s.length, (s.length-1)%3 +1);
    for (i = Math.floor((s.length-1)/3); i > 0; i--){
    outStr += "," + s.substr(-i*3,3);
    }
    prefix + outStr + decimals;
    }else{
    prefix + s;
    }

    I would like to have the endCount to reference a input from the Change_TEXT comp.

    But this doesn’t work:
    numDecimals = 0;
    commas = true
    dollarSign = false;
    beginCount = 0;
    endCount = comp(“CHANGE_TEXT”).layer(“01_count”).text.sourceText;
    dur = 1.5;

    Any suggestions?

    Dan Ebberts replied 8 years, 6 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    March 13, 2018 at 2:12 pm

    You could try this:

    endCount = parseFloat(comp(“CHANGE_TEXT”).layer(“01_count”).text.sourceText);

    Dan

  • Bas V breugel

    March 13, 2018 at 2:25 pm

    You Sir, are a legend!!
    That works like a charm ☺

    One more idea/question. Is there a way to make the counter ease? So it starts quick and slows down at the end?
    If not, no worries this allready is awesome.

  • Dan Ebberts

    March 13, 2018 at 3:20 pm

    you could change

    s = linear()

    to

    s = easeOut()

    Dan

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