2013-01-08 42 views
0

我缺少簡單的邏輯或簡單的代碼。我想做一個貸款計算器在閃存as3像 http://activeden.net/item/loan-payment-calculator-with-slider-as3/897727根據跨行拖動的對象的x計算數量?

我有一個Flash文件,打印一個對象被拖過一行的x。

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

我想要做的是打印出一定量(可以說從1到20 000)根據X。我知道我錯過了一些基本的as3,但我在其他論壇上找不到任何東西。

回答

0

你必須使用比例公式

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; 
+0

感謝喲,這是真正的幫助 – Alex