ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression Count Up Percentage

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lisa Ruiz
Expression Count Up Percentage
on Sep 2, 2009 at 10:41:23 pm

I would like to know if anyone knows of an expression that will let you count up a number with a percentage sign. For example I would like the initial number to read 0% and count up to 100%. I have tried to alter an expression I have that allows a dollar sign and I get an error. Any info would be appreciated.


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Sep 3, 2009 at 12:09:43 am

A text expression like this should work:

beginCount = 0;
stopCount = 100;

beginTime = 0; // start counting at time = 0
countDur = 4; // count for 4 seconds

"" + Math.round(linear(time,beginTime,beginTime + countDur,beginCount,stopCount)) + "%"


Dan



Return to posts index

Lisa Ruiz
Re: Expression Count Up Percentage
on Apr 27, 2010 at 10:55:50 pm

Thank you. This expression worked perfectly.


Return to posts index


Lisa Ruiz
Re: Expression Count Up Percentage
on Sep 14, 2010 at 4:36:49 pm

I'm going to use this expression again, but I need to add a decimal. Do you have an expression for that?

I need to go from 12.3% to 10.1%


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Sep 14, 2010 at 5:07:13 pm

Try this:

beginCount = 123;
stopCount = 101;

beginTime = 0; // start counting at time = 0
countDur = 4; // count for 4 seconds
count = linear(time,beginTime,beginTime+countDur,beginCount,stopCount)/10;
count.toFixed(1) + "%"


Dan



Return to posts index

chandra hope
Re: Expression Count Up Percentage
on Jun 25, 2013 at 9:51:08 pm

Hi there, how could I make this do the opposite and make it count backwards? I tried playing with some of the text but was way off :)

(I already got it to work by just making it a pre-comp and then reversing the time for the purposes of getting what I need done fast, but I was just curious what the code would look like :) )

Thanks!


Return to posts index


Dan Ebberts
Re: Expression Count Up Percentage
on Jun 25, 2013 at 10:19:34 pm

If you want it to reverse the count direction, just change this:

beginCount = 123;
stopCount = 101;

to this:

beginCount = 101;
stopCount = 123;

Is that what you mean?

Dan



Return to posts index

chandra hope
Re: Expression Count Up Percentage
on Jun 25, 2013 at 10:24:06 pm

I tired that and it wouldn't work, did I type something wrong?

beginCount = 55;
stopCount = 0;
beginTime = 55; // start counting at time = 0
countDur = 1; // count for 4 seconds
"" + Math.round(linear(time,beginTime,beginTime + countDur,beginCount,stopCount)) + "%"


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Jun 25, 2013 at 11:43:57 pm

You have it set up to start counting at 55 seconds into the comp, and to count down from 55 to 0 over a 1-second duration. I'm guessing maybe you wanted it to start counting at an earlier time. Just set beginTime to whatever that is. If that's not the issue, please explain what it is that you want it to do.

Dan



Return to posts index


Fasasi Olabanji
Re: Expression Count Up Percentage
on Oct 8, 2012 at 2:34:22 pm

i was have same problem here too but as i Google for solution i saw this post under the search result and it just answer my question thanks for this post.

beginCount = 0;
stopCount = 100;

beginTime = 0; // start counting at time = 0
countDur = 4; // count for 4 seconds

"" + Math.round(linear(time,beginTime,beginTime + countDur,beginCount,stopCount)) + "%"


Return to posts index

Conrad DSouza
Re: Expression Count Up Percentage
on Dec 24, 2012 at 10:18:27 am

useful expression .. but how can I ease-in or ease-out the %tage countdown/countup?

beginCount = 0; stopCount = 100; beginTime = 0; // start counting at time = 0 countDur = 4; // count for 4 seconds "" + Math.round(linear(time,beginTime,beginTime + countDur,beginCount,stopCount)) + "%"


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Dec 24, 2012 at 5:56:32 pm

Try changing "linear" to "ease" or "easeIn" or "easeOut".

Dan



Return to posts index


Iqbal Muhammad
Re: Expression Count Up Percentage
on Feb 14, 2013 at 10:30:39 am

thanks dan , and how if i want give symbol in front of number ?


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Feb 14, 2013 at 6:35:28 pm

Just add it in front like this:

"$" + count

Dan



Return to posts index

Spiro
Re: Expression Count Up Percentage
on Nov 5, 2013 at 3:54:26 pm

I can't figure out how to start with something like "$0000" on screen, and have it count up from there. All the expressions I've found start with "$0." I want to initially start with four zeros.



Return to posts index


Dan Ebberts
Re: Expression Count Up Percentage
on Nov 5, 2013 at 7:44:45 pm

Try this:

beginCount = 0;
stopCount = 100;

beginTime = 0; // start counting at time = 0
countDur = 4; // count for 4 seconds

count = linear(time,beginTime,beginTime+countDur,beginCount,stopCount);
s = "" + Math.floor(count);
while (s.length < 4) s = "0"+s;
"$"+s

Dan



Return to posts index

John Hernández
Re: Expression Count Up Percentage
on Mar 31, 2016 at 12:23:30 am

Hey Dan, I know this is an old post. Just wanted to ask... Where did you learn all that? I've been an independent producer since 3 years ago and AE is still one bigger weaknes. Greetins and thanks in advance.


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Mar 31, 2016 at 12:54:25 am

I just jumped in when AE got expressions. I hadn't really seen JavaScript before that, so I'm still learning as I go...


Dan



Return to posts index

Liran Tabib
Re: Expression Count Up Percentage
on Apr 22, 2016 at 6:35:14 am

Hi Dan
Just wanted to say Thanks for spreading your knowledge on Expressions. I learned a lot from reading your Posts and Articles over the years, and today I love using expressions thanks to you.
I've created a Counter Preset that will save everyone the headache of creating counter Animations:
http://www.vdodna.com/products/counter-preset/

I'll Send you a gift copy through your site.
Thanks
Liran


Return to posts index

Joshua Bird
Re: Expression Count Up Percentage
on Apr 22, 2016 at 6:29:14 pm

Hi Dan,

Your expressions are really good and could use your expertise on figuring something similar to this one out.

I have two layers. Layer 1's opacity goes from 0-100% (this percentage is controlled by the progress of another layers effect that I have already linked it to). I want layer 2's opacity to go from 0-100% as well but only start when Layer 1 is at 87%. How would I do that and end at 100% when Layer 1 reaches 100%?

Thanks,

Josh


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Apr 22, 2016 at 6:45:54 pm

This should work:
v1 = thisComp.layer("layer 1").transform.opacity;
linear (v1,87,100,0,100)


Dan



Return to posts index

Joshua Bird
Re: Expression Count Up Percentage
on Apr 22, 2016 at 6:54:13 pm

Hi Dan,

Worked perfect. Thank you. So I can learn more about the coding structure for AE can you explain what each number in this string represents (v1, 87, 100, 0, 100)?

Does:
v1 rep the opacity of layer 1 at any given time
87 target start value of layer 2
100 end value of layer ?
0,100 change opacity of layer 2 from 0-100

Thanks,

Josh


Return to posts index

Dan Ebberts
Re: Expression Count Up Percentage
on Apr 22, 2016 at 7:08:33 pm
Last Edited By Dan Ebberts on Apr 22, 2016 at 7:09:15 pm

>v1 rep the opacity of layer 1 at any given time

Yes.

The second line of the expression essentially says "as the opacity of layer 1 varies from 87 to 100, vary the opacity of this layer from 0 to 100". It's in the AE help manual under Interpolation methods.

Dan



Return to posts index

Joshua Bird
Re: Expression Count Up Percentage
on Apr 22, 2016 at 7:11:39 pm

Thank you again. I will look this up.

Best,

Josh


Return to posts index

Christoph Heimer
Re: Expression Count Up Percentage
on Jan 4, 2017 at 4:57:02 pm

Thanks for all the good advice so far. But how is it possible to make the percentage "slider controllable"?

Basically what I wanna do is take this: and add a fourth number, that is being controlled be a sum of two of the other numbers. But I can't figure it out how to add the two numbers on top of each other. So I either need to understand that, or come up with a way to have a slider on my text layer that simply controls the number.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]