Results 1 to 10 of 10
Thread: slider with numbers
-
March 5th, 2012, 02:01 AM #165Registered User
postsslider with numbers
So i got the slider itself working, but how would I, for example with a slider length of 1 to 100 pixels create an array of numbers between 20 and 200? (or simply between numbers x and y)?
I figure theres tutorials all over the web for a formula, and that theres even a simple 9th grade math equation for it, but im simply too lazy.
Thanks in advance for any help..
-
March 5th, 2012, 02:41 AM #2
Well I was going to just give you the equation until I read that
It is a very simple problem: you want a linear function that maps 1->20 and 100->200. That's enough data to solve the equation y=mx+b.
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
March 5th, 2012, 11:59 PM #365Registered User
postsalright, so maybe im just a moron, but i am having trouble and learn much better through visual example. from x values of the slider being between 10 to 100, and desired output being between 20 to 200, and variable:value is the output depending on slider.x(that x value being between 10 and 100).... what equation do i plug in to get value?? Maybe just cuz i aint been in school for a while, maybe cuz im tired, maybe both, idk. please just give me the answer XP
-
March 6th, 2012, 07:25 AM #4
Oh the input value is from 10 to 200? That makes it even easier. You really can't figure out how to scale the interval 10-100 to 20-200?
Here's a visual example: Tommy has 10 apples. Sally has 20 apples. How many times more apples does Sally have than Tommy?
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
March 6th, 2012, 08:38 AM #5218Carebear
postsUsually i make the sliders to return Number from 0 to 1 and then transform it to any value needed. Simple percentage usage. I that case the transformation will look something like this:
value = minValue + (Math.abs(maxValue - minValue)*sliderPercent);
in your 20 to 200 case:
value = 20 + (Math.abs(200-20)*sliderPercent);
Props to The Canadian for the visual aids
-
March 6th, 2012, 09:31 AM #6
I knew someone was just going to give it to him eventually. Although, if your input is 10-100, there is a much simpler equation to use. Perhaps there's some constant you can multiply it by…
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
March 6th, 2012, 10:26 AM #7218Carebear
posts
-
March 6th, 2012, 11:56 AM #8
I'm sure there's enough leading questions in this thread to figure it out
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
-
March 6th, 2012, 03:12 PM #965Registered User
postsyes thank you everyone. the answer was very simple. I needed the formula because the min-max values and variables would be different for each slider i make. thanks.
-
March 6th, 2012, 11:05 PM #10
I gave you the formula in the second post
Proud Montanadian
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .

Reply With Quote


Bookmarks