Just thought id share this as it will come in useful for someone in the future. Ever wanted to use the PMT function from Excel in Flash? Well, after some digging, and after some modifications, here is it.
PMT = function(r,np,pv,fv,t) {
/*
r = the percentage rate of the loan. (decimal: 8% = 0.08)
np = number of monthly payments (integer)
pv = present value or principal of the loan (decimal)
fv = future value of the loan (after payments) (decimal)
t = paid before or after (0/1)
*/
var vPow = Math.pow( ( 1 + r ), np );
var vT = (t == 0) ? r : ( r /( 1 + r ) );
return ( (vPow * pv) - fv ) / (vPow - 1) * vT;
}
Don’t say I never give you anything! (Thanks OJ for your hint on consolidating the last 2 lines into 1)