0
votes

I am missing simple logic, or simple code. I want to make a loan calculator in flash as3 like http://activeden.net/item/loan-payment-calculator-with-slider-as3/897727

I have a flash file that prints x of an object that is dragged across a line.

scrubber.x = _point.x;
tf1.text = String(_point.x);

What I want to do is to print out a certain amount (lets say from 1 to 20 000) depending on the x. I know I am missing some basic as3 but I couldn't find anything on other forums.

1

1 Answers

0
votes

You have to use percentage formula

var a:Number = 320;//this is the amount on the line - you have to calculate it taking the position of the scrubber in relation to the position of the line
var b:Number = 640;//this is the 100%, 640 is the example and it will be the width of your "line"
var max_loan:Number = 10000;
var p:Number = a/b;//this is the percentage value, here it will be 320/640=0.5

var available_loan:Number = max_loan * p;//this is what you will display, here it will be 5000;