Kahlil
06-21-2002, 05:01 AM
I got a simple code taken from the Flash Actionscript (from the source) the code is very straight forward. However it doesnt execute as properly.
Program: supposed to give an string out put (message) saying if you over pay, underpay, or payd fully. So it uses an if, else, else if function.
Problem: for some strange reason that I am not able to see, the first output is wrong. This mean that if I put a smaller number the output keeps telling me that is payed in full.
----Code----
on (press) {
amountPaid = Number(paid.text);
amountOwed = Number(owed.text);
if (isNaN(amountPaid)) {
message.text = "What the **** you entered??";
} else if (amountPaid<amnountOwed) {
difference = amountOwed-amountPaid;
light.gotoAndStop("Off");
message.text = "You underpaid your bill by "+difference+"dollars.";
} else if (amountPaid>amountOwed) {
difference = amountPaid-amountOwed;
light.gotoAndStop("Hot");
message.text = "You overpaid your bill by "+difference+" dollars.";
} else {
light.gotoAndStop("On");
message.text = "You have paid your bill in full.";
}
}
on (release) {
light.gotoAndStop("Off");
message.text = "";
}
Program: supposed to give an string out put (message) saying if you over pay, underpay, or payd fully. So it uses an if, else, else if function.
Problem: for some strange reason that I am not able to see, the first output is wrong. This mean that if I put a smaller number the output keeps telling me that is payed in full.
----Code----
on (press) {
amountPaid = Number(paid.text);
amountOwed = Number(owed.text);
if (isNaN(amountPaid)) {
message.text = "What the **** you entered??";
} else if (amountPaid<amnountOwed) {
difference = amountOwed-amountPaid;
light.gotoAndStop("Off");
message.text = "You underpaid your bill by "+difference+"dollars.";
} else if (amountPaid>amountOwed) {
difference = amountPaid-amountOwed;
light.gotoAndStop("Hot");
message.text = "You overpaid your bill by "+difference+" dollars.";
} else {
light.gotoAndStop("On");
message.text = "You have paid your bill in full.";
}
}
on (release) {
light.gotoAndStop("Off");
message.text = "";
}