Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6074081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:20:33+00:00 2026-05-23T10:20:33+00:00

I currently have a vertical slider that is controlled by the user using startDrag.

  • 0

I currently have a vertical slider that is controlled by the user using startDrag. The puck is restricted in movement by a track movieclip that is 115px high.

private function init():void
{
    puck.y = (track.height-puck.height)/2;
    puck.buttonMode = true;
    puck.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
}
private function sendNewValue():void
{
    trace(Math.round(puck.y-track.y+(puck.height/2)));
    var newVal:Number = ; //need some math magic here
    dispatchEvent(new ToolEvent(ToolEvent.SCALE,1));
}
private function onMouseDown(evt:MouseEvent):void
{
    this.stage.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
    puck.startDrag(false,new Rectangle((track.x + (track.width/2))-(puck.width/2),track.y-(puck.height/2),0,track.height));
}
private function onMouseUp(evt:MouseEvent):void
{
    puck.stopDrag();
    sendNewValue();
}

I can get a value from it using Math.round(puck.y-track.y+(puck.height/2)), which gives me values between 1 and 115 based on the position of the puck.

Now sadly maths is not my strong point at all (helpful for a programmer!), so would someone please explain how I can convert these values so that:

1 = 2
115 = 0
midpoint (115/2) = 1

Edit: kind of like the question here: How do I reverse my sound volume math for my volume slider?, but as well as inverting the value I need to adjust it on a scale.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:20:33+00:00Added an answer on May 23, 2026 at 10:20 am

    if you’re looking for a linear function such that:

    f(1)=2 and f(115) = 0
    
    F(x) = 115/67 -x/67 will work
    

    Generalization:

    If you looking for a linear function f(x) = a.x + b such that:

    f(x1)=y1
    f(x2)=y2
    

    then the solution is:

    a=(y1-y2)/(x1-x2)
    b=y1 - x1*(y1-y2)/(x1-x2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an MS Access application that connects to a PostgreSQL database via
I currently have an existing database and I am using the LINQtoSQL generator tool
I currently have a DetailsView in ASP.NET that gets data from the database based
I have been working with the slider and am using the following code: $(function(){
I currently have an NSView that draws a grid pattern (essentially a guide of
I currently have a GridView scrolling vertically, and everything works fine. But now that
I want to remove the Vertical slider from QWebView that displays GoogleMap with current
How to create vertical gradient in flex. What i currently have is a horizontal
I currently have speakers set up both in my office and in my living
We currently have a company email server with Exchange, and a bulk email processing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.