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;
break;
case "2" :
numberOfMonths = 48;
break;
case "3" :
numberOfMonths = 60;
break;
}
// 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
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