FlashMX 2004
I am having a problem with input text (numbers).
The values to be enterred can be between 1 and 20.
I am currently using a small 2 frame loop to ensure this is done correctly:
in frame 1 it has the following very simple actionscript:
if (myvariable>20) {
myvariable=20;
}
if (myvariable<1) {
myvariable=1;
}
in frame 2 it has:
gotoAndPlay(1);
so essentially, frame 1 checks the values being enterred are between 1 & 20, and will change them if they are not.
As well as the user being able to enter a number between 1 & 20, I also have buttons that increment and decrease the number - again very simple actionscript on the buttons:
Down Button:
on (press) {
if (myvariable>1) {
myvariable -=1;
}
}
Up Button:
on (press) {
if (myvariable<20) {
myvariable+=1;
}
}
The problem I have is this - if I enter a number - lets say for example 7, it does not read this number as 7 if I press the up button - it seems to think it is 70 so becomes 71 and therefore immediately resets to 20. It does this with any number I enter between 1 and 20, so if I enter 17, and press the up button it becomes 171 and again immediately resets to 20.
However, if I press the down button I do not have this problem - it does what it should - just lower the number by one. So using 7 again as an example - pressing the down button will result in it becoming 6, all that works fine with all numbers between 1 & 20 when pressing the down button.
So my question is, how do I correct this? Honestly it’s so frustrating!
I am using this loop just because it is simple to do - if there are other ways of ensuring the input is correct to start with I would be happy to use that method - I simply don’t know how to do that or if it is even possible. Also I would prefer the check to be done (and corrected if necessary) when someone clicks out of the input box rather when they may still be trying to enter - again I do not know how to do that or if it is possible.
PS. I am using Flash MX 2004 as it’s the only legal copy I own, but I can’t imagine this problem would not happen in CS3 or CS4 (Yes - It has been a long time since I used flash).
Thanks in advance for any advice offered.