if (_root.playername == (void))
{tellTarget (specialmessages) gotoAndPlay (2);}
else if (_root.playerbirth == (void))
{tellTarget (specialmessages) gotoAndPlay (16);}
else if (_root.playername == (void) and _root.playerbirth == (void))
{tellTarget (specialmessages) gotoAndPlay (29);}
else
nextFrame ();
}
On my screen are two input boxes (playername and playerbirth) and a button that advances to the next screen. The above code is for the button. All I’m trying to do is make it so that if there is nothing in the input boxes, then an error message will come up. The only way I could think of to represent nothing is “void” but it doesn’t work. (special messages is the mc that contains my error messages)
using null works, but it wont check correctly… for example:
When the screen first comes up, and you hit the button without putting something in either field, it will say “you did not enter a name or birthdate” which is correct. However, if you put something in each box and erase it, you can pass through. For some reason once you put something in a box, it always thinks there is something there, even if you erase it.
Ok, I have made a few changes to your above script.
The first if statement should be the one to check if both are empty. Then I also added if it was == to “” in case anyone deleted the content inside it registers as “” and you need to check for that.
And I also changed your tellTarget. tellTarget has been out since about Flash 4 I believe, although I noticed a lot of Flash 5 tutorials use it, which makes no sense because there is an easier way.
|| is a boolean “or” statement. So it says if <I>This</I> <B>or</B> <I>That</I> are true than do the following. It means any of the statements can be true, but not all of them need to be.
And && is a boolean “and” statement. So it says if <I>This</I> <B>and</B> <I>That</I> are true, then do the following. It means both statements MUST be true.
wow, all this time using tellTarget and I had no idea you could just do that… and yeah, outputting the error to a dynamic text box is a thousand times better.
Yeah, I figured outputting to a textbox would be better and easier
I tested myself using the trace(expression) function in Flash. Then after I got everything working I removed the traces and threw in a dynamic text box and displayed it that way.
On another note: I put the first if statement as being if both are empty because in your original script if both were empty it only said the playername box was empty since that was first in the chain of if statements. So checking if both are empty first is the way to go, if both aren’t empty, then check for playername, then check playerbirth, then if all of that is fine… just play nextFrame()