1 Reply Latest reply on Jan 23, 2009 11:22 AM by matthew horn

    Savings calculator in flex

    visser215 Level 1
      Hi, i am looking for a flex example / source code which i can use to calculate the return on savings account.
      Input is starting amount and amount per month, duration and interest rate.
      See this example, Savings calc example or , which is javascript based

      Any example which can give me a quick start is welcome. With a chart is even better. example 2
        • 1. Re: Savings calculator in flex
          matthew horn Level 3
          Here you go:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
          <mx:Script>
          <![CDATA[
          private function getResult():void {
          var interest:Number = Number(ti2.text) / 12;
          var n:Number = Number(ti3.text) * 12;
          var pv:Number = Number(ti1.text);
          var pmt:Number = Number(ti4.text);

          var multiplier:Number = calcMultiplier(interest, n);
          var fv_principal:Number = multiplier * pv;
          var fv_payments:Number = pmt * ((multiplier - 1)/interest);

          var fv:Number = pv * multiplier + pmt * ((multiplier-1)/interest);

          result.text = "Result: " + fv;
          }

          private function calcMultiplier(interest:Number, n:Number):Number {
          return Math.pow((1+interest), n);
          }
          ]]>
          </mx:Script>

          <mx:Label text="Initial Deposit"/>
          <mx:TextInput id="ti1" text="50000"/>

          <mx:Label text="Interest Rate"/>
          <mx:TextInput id="ti2" text=".06"/>

          <mx:Label text="Number of payment periods (years)"/>
          <mx:TextInput id="ti3" text="30"/>

          <mx:Label text="Periodic Payment"/>
          <mx:TextInput id="ti4" text="400"/>

          <mx:Label id="result" text="Result: "/>


          <mx:Button id="b1" click="getResult()" label="Get Result"/>
          </mx:Application>

          matt horn
          flex docs