Example:
Use the calculator above to work out your monthly re-payments.
First of all open swishmax and create a movie 313 x 304
Change the bg colour to grey #808080.
Now create 3 input text boxes
Box 1 name Loan Amount and give it a variable name of intprincipal
Box 2 name Anual Interest Rate and give it a variable name of floInterest
Box 3 name Term Of Loan and give a variable name of intTerm
Place static text at the side of each corresponding box Loan Amount, Anual Interest Rate, Term Of Loan.
You should have something looking like Fig.1
Fig.1
On Scene_1 add the following Code.
|
//************************************************************//
//*Loan/Mortagage Calculator *// //*Code By Craig Lowe *// //*Visit www.craigspage.co.uk *// //*Visit www.shish-db.com *// //*Kind Regards, Craig... *// //*The Notice must stay in place. *// //************************************************************// onLoad () { //Initial Loan Amount intprincipal="5000"; //Anual Interest floInterest="6.0"; //How Many Years To Pay Back Over intTerm="20"; //Displays total number of payments that need to be made TotRepayment=""; //Displays how much payments will be each month mnthly=""; //Division of amount to years over _1st=""; //Monthly Payments less interest _2nd=""; //total interest _3rd=""; } |
Now Create a Calculate button and add the following code to that.
|
on (release) {
mnthly=_3rd/TotRepayment+_2nd; } on (press) { //Works out total payments TotRepayment=intTerm*12; //Divides amount by total years _1st=intprincipal/intTerm; //Works out monthly payments less interest _2nd=_1st/12; //Works out total percent of interest _3rd=intprincipal/100*floInterest; } |
You now should have something looking like Fig.2
Fig.2
Now create a Clear/Reset Button and add the following code to it.
|
on (release) {
//This sets all counters to zero //Initial Loan Amount intprincipal=""; //Anual Interest floInterest=""; //How Many Years To Pay Back Over intTerm=""; //Sets Number of payments to 0 TotRepayment=""; //Amount of payment each month mnthly=""; //Division of amount to years over _1st=""; //Monthly Payments less interest _2nd=""; //total interest _3rd=""; } |
You should now have something looking like Fig.3
Fig.3
Now you need to create 2 Dynamic Text Boxes
Box 1 name Number of payment with a variaable name of TotRepayment
Box 2 name Monthly Payments with a variable name of mnthly
Add the corresponding text to the side of each box Number of payment, Monthly Payments.
You should now have something looking like Fig.4
Fig.4
Create 3 more dynamic text boxes.
Box 1 name 1 with a variable name of _1st
Box 2 name 2 with a variable name of _2nd
Box 3 name 3 with a variable name of _3rd
Place these 3 boxes of the main stage, all these are used for is handling data
For later use of producing the final outcome.
If you are going to be using this generator in a pop-up window, you might want to add a Close Button to it.
If so create the Close Button and add the following code to the button.
|
on (release) {
javascript("window.close()"); } |
Your final movie should look something like Fig.5
Fig.5
Press Ctrl+T to test in player.





