-
Adding 1 to a NUMBER
Hi. I want to be able to add/subtract 1 to a number that is in a dynamic text box, when the user presses the up or down arrows (up to add down to subtract). I know how to control the up and down arrows, my problem is adding 1. I can't seem to mathematically add 1... I can make it so that when the user clicks the up arrow, it adds a 1 to whatever was in it before, so basically, if the contents was 02 before, it would turn into 021... But I want it to go from 02 to 03, or 02 to 01! HOW CAN I DO THIS?!?!
Any help is GREATLY appreciated!!
Thanks,
Sportzguy933
-
Flashmatics
they all have proceeding zeros?
-
Ryan Thomson
if the number in the text box is a variable (like textField == 1) you would just put textField++ on your up button and textField-- on your down button. To include a 0 before changes things a bit, you would have to put something like:
"0" + textField++ which would include a 0 before your number which would work up until you hit a 3 digit number cause then it would be som ething like 0100 for 100 so you would need an if statement to remove the 0 if the number is more than 99.. Im sure I've provided too much info so feel free to ask me what the hell im talking about lol
good luck!
-
Hey. I understand exactly what you're saying, the problem is, it's not working. I'd actually rather not have the "0" in front, so that's not a problem. The probem is that I've done what you suggested, and it doesn't work! The code I have now is:
on (keyPress "<Up>") {
textBox++
}
And it doesn't add one! I just get "NaN", or "Undefined".
-
textBox="0"+(Number(textBox)+1);
if you don't want the String "0" just keep the second part:
Number(textBox)+1;
gparis
-
Thanks so much for the help! It worked!
~Sportzguy933
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|