ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How To User Input Max Number in Essential Graphics for Number Counter Slider

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Vy Nguyen
How To User Input Max Number in Essential Graphics for Number Counter Slider
on Jan 11, 2018 at 4:38:11 am

Hello all,

I am creating a motion graphics template using essential graphics editor and I want my client to be able to input a number and have the master composition animate and count up to that number from zero.

I am using a basic slider counter up and referencing that slider in the essential graphics template, but when I input a number into the essential graphics, all it does is add key frames which can mess up the original counter.

What are my options to make it so that when inputting a value in the essential graphics, that number will be the highest value that my original comp animation will count up to?


Return to posts index

Scott McGee
Re: How To User Input Max Number in Essential Graphics for Number Counter Slider
on Jan 11, 2018 at 8:26:37 am

Personally I wouldn't even bother using a slider, if that's all you want to use it for. I'd just copy and paste this into your source text and adapt.

tStart = inPoint;
startCount = 0;
endCount = 3000000;
countDur = 14;
t = Math.max(time-tStart,0);
Math.round(linear(t,0,countDur,startCount,endCount))
stolen from Dan Ebberts


To adapt I'd create two additional text layers I've called them "End Count" and "Max Duration" to match Dan's work and added a few safety features.

tStart = inPoint;
startCount = 0;
endCount = parseFloat(thisComp.layer("End Count").text.sourceText);
if (isNaN(endCount)) endCount = "0";

countDur = parseFloat(thisComp.layer("Max Duration").text.sourceText);
if (isNaN(countDur)) countDur = "0";

t = Math.max(time-tStart,0);
Math.round(linear(t,0,countDur,startCount,endCount))


I've just added that if the person you are giving this to enters words or nothing, it'll default to zero.

Then in Essential Graphics, you can put the source text for these two layers into it instead and they just have to type the number in for Max Number and how long they want it to be...(There's no way to extend the comp, so remind them what the max length is. Or again you can add a default, so if they go above that number it'll only go as big as the comp).

Just because it took 2 secs, the below expression. I've added that feature as well (highlighted in black). Just change 20 to the max length so they can't go above it, but they can go less if they ever need to.

tStart = inPoint;
startCount = 0;
endCount = parseFloat(thisComp.layer("End Count").text.sourceText);
if (isNaN(endCount)) endCount = "0";

countDur = parseFloat(thisComp.layer("Max Duration").text.sourceText);
if (isNaN(countDur)) countDur = "0";
if (countDur > 20) countDur = "20";

t = Math.max(time-tStart,0);
Math.round(linear(t,0,countDur,startCount,endCount))

Hope this is of use to you


Return to posts index

Vy Nguyen
Re: How To User Input Max Number in Essential Graphics for Number Counter Slider
on Jan 11, 2018 at 1:55:08 pm

Scott,

You solved my problem! Thank you so much.

I'm very new to expressions / scripting so I will look more into Dan Ebbert's resources online. Any additional resources would be gladly appreciated!


Return to posts index


Scott McGee
Re: How To User Input Max Number in Essential Graphics for Number Counter Slider
on Jan 11, 2018 at 9:08:18 pm

Not a problem.

To be fair I learnt all I have from Dan's http://www.motionscript.com, he has a few links to external places. Youtube and here has been a big help.

http://www.jjgifford.com/expressions/basics/index.html This place is quite good, some of the java has change since then, but it'll still work.

hope that helps getting you started.


Return to posts index

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