#1 (permalink)  
New Member
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Need help

I am doing a final project and for some reason the code I am using is not working, even though I copied it down exactaly as I was told to, does anyone see any problems with this code?

*code start*

import flash.events.MouseEvent;

// Function to calculate the monthly payment
calc_btn.addEventListener(MouseEvent.CLICK, calculatePayment);
function calculatePayment(event:MouseEvent):void
var numberOfMonths:Number;
switch (lengthOfLoan_mc.value)
case "1" :
numberOfMonths = 36;
case "2" :
numberOfMonths = 48;
case "3" :
numberOfMonths = 60;
// Convert input values into Interger numbers
var Loan:Number = int(loanAmount_txt.text);
var Rate:Number = int(interestRate_txt.text);
// Determine the monthly interest rate
var monthlyRate:Number = (Rate/12)/100;
// Calculate part of the formula using math ower function
var factor:Number = 1 - Math.pow(1 + monthlyRate, - numberOfMonths);
// Calculate the payment; round to the nearest dollar
var payment:Number = Math.round((monthlyRate/factor)*Loan);
// Display the resulting monthly payment
monthlyPayment_txt.text = String(payment);
//set ComboBox to displaythe initial prompt, No. of Months
lengthOfLoan_mc.selectedIndex = -1;

*code end*

loanAmount_txt and interestRate_txt and both imput text boxes that numbers are suppoused to be entered into. And lengthOLoan_mc is a comboBox that is used in the equation. The results are suposed to be put into the dynamic text box called, monthlyPayment_txt. The button that is clicked to start it is called, calc_btn.

When I mean it is 'called somthing' I mean the instance name is.

It keeps showing errors relating with this line

*line start*
var factor:Number = 1 - Math.pow(1 + monthlyRate, - numberOfMonths);
*line end*

The errors are:

*error start*
1084: Syntax error: expecting identifier before var.
1084: Syntax error: expecting left paren before colon.
1084: Syntax error: expecting identifier berore 1.
1084: Syntax error: expecting identifier before minus.
*error end*

All help/suggestions are appreciated
Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

All times are GMT -5. The time now is 05:18 AM.
vBulletin® Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.