Actionscript 3 根据横线拖动的对象的x计算数量?

Actionscript 3 根据横线拖动的对象的x计算数量?,actionscript-3,flash,Actionscript 3,Flash,我缺少简单的逻辑或简单的代码。我想用flash as3做一个贷款计算器 我有一个flash文件,它打印一个物体的x,这个物体被拖过一条线 scrubber.x = _point.x; tf1.text = String(_point.x); 我想做的是根据x打印出一定数量(比如1到20000)。我知道我缺少一些基本的as3,但我在其他论坛上找不到任何内容。你必须使用百分比公式 var a:Number = 320;//this is the amount on the line - you

我缺少简单的逻辑或简单的代码。我想用flash as3做一个贷款计算器

我有一个flash文件,它打印一个物体的x,这个物体被拖过一条线

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

我想做的是根据x打印出一定数量(比如1到20000)。我知道我缺少一些基本的as3,但我在其他论坛上找不到任何内容。

你必须使用百分比公式

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;