Link to home
Start Free TrialLog in
Avatar of ssdesign
ssdesign

asked on

Mortgage calculation equation for Actionscript

Hi,

I am trying to create a mortgage calculator with Graphing.

Take a look at the equation and sample here:
http://www.moneychimp.com/articles/finworks/fmmortgage.htm

I am not finding a way to write an ectionsctipt for the Graph creation.

Can someone point me to right direction? Or tell me what should be the way to create this in flash?
I can give more points to the one who can solve this.

thanks.
Avatar of Cerf
Cerf

an Idea... not meant to be the final solution...

make a rectangle mc, then to dinamically create the bars, use attachMovie, and for the height, you can use something as simple as _yscale

need help with any of the topics mentioned above?

Cërf.
i'm sure it's going to be a lot of x y calculations and also a lot of work, but still seems like challenging fun
Avatar of ssdesign

ASKER

The question is not about the graph creating, its about how to calculate Mortgage values based on the equations on th elink I gave above.
Sorry if i had been not clear in my question.

What i want to know is how to exactly create the mortgage calculator in flash as in the link above.
oh, and then what do you mean with the eqs? do you need the eqs? or you have em and don't know how to implement them? I have never worked with java but I know it has a powerful math engine, so if the eqs have integrals, derivates and limits (if those are proper names in english) I'm out of the game too :-)

Let me know,

Cërf.
Sorry, I only looked at the graph, and did not notice the eqs where below :-(
try this:

->FLA:
3 text input boxes
2 text dynamic boxes
1 button: instance name: btnCalculate

vars assigned to each, in order: years, loan, interest, rate, payment

->Script
//The one and only frame :-)
//AS

var nPayments //number of payments

btnCalculate.onRelease=function(){
      rate = (interest/100)/12;
      nPayments = years * 12;
      payment = "$" + Math.round((loan * (Math.pow((1 + rate),nPayments)) * rate) / (Math.pow((1 + rate),nPayments) - 1))
      }

hope this helps,

Cërf.
Actually, thats still way off my question.

I have seen text based mortgage calculators around flashkit and everywhere.

I want a GRAPH based calculator, one which will show graphical representation.

Did u ever looked at the link I have given above?
yes, I actually did!
When I wrote about how to make the graphs, you told me that it was about the eqs, then I took the time to write the eq in AS and you tell me that is the graphics what you want. :-s

You will need the values anyway, so what you will need to do is to make a for loop taking the control var out of the years and calculate the anual debt with this formula Debt(n) = Pzn - a[(zn - 1)/(z - 1)], then you need to graph each one of those values. I don't know how to calculate the equity.
Ok so i am getting it, What you have done is converted the Maual payment euqation to find "a" into actionscript.

As you can see, I would need the equation for Debt as you said to be converted to actionscript. But in that equation, I need to know "a".

Does it mean i calculate "a" first and then calculate Debt? I tried that in a for loop and was getting NEGATIVE values.

Ok,
I ported the other EQ to AS but I don't know if it is throwing good numbers, at least those are not negative now...

var nPayments //number of payments
var n,P,Z,a // var names as in the website... clearer

btnCalculate.onRelease=function(){
      rate = (interest/100)/12;
      nPayments = years * 12;
      payment = Math.round((loan * (Math.pow((1 + rate),nPayments)) * rate) / (Math.pow((1 + rate),nPayments) - 1))
// New code...
      Z = 1+rate;
      a = payment;
      P = loan;
      n = years;
      Debt_Array=new Array();
      for(i=1; i<n+1; i++) {
        Debt_Array [i] = P * Math.pow(Z,i) - a * ((Math.pow(Z,i)-1)/(Z-1)) ;
        trace(Debt_Array[i]);
      }      
      }

I might not anwser back in a while because I need to go out, but as soon as I come back I will take a look at the Q.

Cërf.
Cool,
It defemitely looks like on the right track but have a doubt.

Actually at the end of the for loop, the DEBT should be '0' zERO

Also there was a small mistake in the code which I corrected.

for(i=1; i<n+1; i++) {

Should be

for(i=0; i<n; i++) {

Otherwise, If i set the years to 30, n+1 becomes 301 instead of 31.
alright,
now, I agree with you about the debt being 0(zero) at the end, but Don't know how to fix it, since finances is not my area, the EQ is as shown on the webpage, but somehow I think it is not throwing the right results
ok, i have reposted a linked question for new people to look at this.

I will consider your help while accepting the answer.
ASKER CERTIFIED SOLUTION
Avatar of Cerf
Cerf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial