Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesTrainingCreative Cloud DebateFAQ

whole number slider

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
ben wolfinsohnwhole number slider
by on Nov 1, 2012 at 6:58:57 am

I am new to expressions and sliders - is it possible to create a slider that only works with whole numbers, no decimals?


Return to posts index
Reply   Like  

Jamie BradshawRe: whole number slider
by on Nov 1, 2012 at 1:32:52 pm

copy the following expression into your Slider:

Math.floor(value);

Math.floor rounds down whatever number is inside the bracket.

I hope this helps.

JimJam•Graphics
http://www.jimjamgraphics.com/


Return to posts index
Reply   Like  

Darby EdelenRe: whole number slider
by on Nov 1, 2012 at 3:14:10 pm

[Jamie Bradshaw] "Math.floor(value);

Math.floor rounds down whatever number is inside the bracket."


There's also:

Math.round()

Rounds to the nearest number, Math.round(0.5) returns 1, Math.round(0.4) returns 0 for example

Math.ceil()

Returns next highest whole number, Math.ceil(0.0001) returns 1 for example


And to complete the picture:

Math.floor()

Returns next lowest whole number, Math.floor(1.9) returns 1 for example

Darby Edelen


Return to posts index
Reply   Like  


ben wolfinsohnRe: whole number slider
by on Nov 1, 2012 at 4:29:08 pm

sorry, this is the first slider and expression i've ever made, where do i paste that exactly?
thanks!


Return to posts index
Reply   Like  

Darby EdelenRe: whole number slider
by on Nov 1, 2012 at 5:36:31 pm

[ben wolfinsohn] "sorry, this is the first slider and expression i've ever made, where do i paste that exactly?
thanks!"


That depends. If you just want to take the slider value and round it then your entire expression (applied to the slider property) might look like this:

Math.round(value);

You could use floor() or ceil() alternatively.

Darby Edelen


Return to posts index
Reply   Like  

ben wolfinsohnRe: whole number slider
by on Nov 12, 2012 at 11:02:00 pm

I'm still seeing the decimal point in the slider bar. is there no way to remove that then?


Return to posts index
Reply   Like  


Dan EbbertsRe: whole number slider
by on Nov 13, 2012 at 12:32:40 am

If you're using a text layer, you could use a source text expression like this:

s = effect("Slider Control")("Slider").value;
s.toFixed(0)


Dan



Return to posts index
Reply   Like  

ben wolfinsohnRe: whole number slider
by on Nov 13, 2012 at 1:04:00 am

sorry, i'm a bit confused. let me try to explain.

I have 3 comps, each comp is time remaped, each remap has an expression like this -
comp("head contol").layer("head contols view 1").effect("head turn (18)(1-forward)")("Slider")/23.976

and all 3 of the comps are pointing to the same slider.

so where would i put the code you're talking about? and would I put it in all 3 comps?


Return to posts index
Reply   Like  

Dan EbbertsRe: whole number slider
by on Nov 13, 2012 at 1:58:27 am

Now I'm confused. If you're not displaying the value, why do you care about the decimal point?

Is it that you have the rounding expression applied to the slider, but when you divide that value by 23.976 you don't get a whole number? How about something like this instead:

framesToTime(comp("head contol").layer("head contols view 1").effect("head turn (18)(1-forward)")("Slider").value)


Dan



Return to posts index
Reply   Like  


ben wolfinsohnRe: whole number slider
by on Nov 13, 2012 at 2:44:10 am

that didn't seem to do it.

basically i have a comp with 18 frames, each frame has a drawing of a different perspective of a head. with the slider i can easily scroll through the different faces when i use it with timeremaping. the slider goes from 0-17. BUT, I don't need the slider to display 1.3 for an example, cuz i don't have .3 of a frame. i only need it to show numbers 0-17 in the slider bar.

does that make sense? is it possible?


Return to posts index
Reply   Like  

Dan EbbertsRe: whole number slider
by on Nov 13, 2012 at 3:22:37 am

If you put the Math.floor(value) expression on the slider, you'll get 0.00, 1.00, etc., but I don't think there's any way to get rid of the ".00" part, if that's what you're asking.

Dan



Return to posts index
Reply   Like  

Dan EbbertsRe: whole number slider
by on Nov 13, 2012 at 3:30:38 am

Which number are you concerned about, the slider value or the time remapping value? I'm wondering if maybe you expected the time remapping value to be in frames instead of seconds.

Dan



Return to posts index
Reply   Like  


ben wolfinsohnRe: whole number slider
by on Nov 13, 2012 at 4:24:07 am

just wanted the slider value to be, but I guess I can just ignore the the decimal place, and just look at the whole number and it works fine. 2.01 or 2.93 gives me the same results. so i'll just ignore the other to digits and all is good.


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSMAGAZINESTOCKYARDVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2013 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]