How do I implement the use of "void?"

OK here’s something I wrote:

on (release) {

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)

any help ? :\

I’d just make it

if(something == “”) {
bla bla
}

or try

if(something == false) {
bla bla
}

just replace “something” with a textbox!

or

_root.playername == null

Null checks to see if it is empty (aka nothing there)

lol “null” in my language means zero! (0) :stuck_out_tongue:

LOL… same here in a way. We have a billion words for 0 in english.

yeah I mknow I remember it from my english classes!
What was it again … love, nil, null, zero , o , …etc (nothing more comes up right now)

I use

!_root.playername

(but not for strings lol)

Yeah, I use that too. I use that if something is set to “false”

You had me for a second there, I was about to be like “YOU CAN DO THAT FOR STRINGS!!!”…then I read the parenthesis.

ok… using “” and false doesn’t work at all

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.

Just thought I’d bump this real quick, maybe no one saw my post yesterday and I didn’t want to start a new one.

Anyways yeah that’s weird how the null thing is working…

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.

on (release) {
	if ((_root.playername == null || _root.playername == "") && (_root.playerbirth == null || _root.playerbirth == "")) {
		_root.specialmessages.gotoAndPlay(29);
	} else if (_root.playername == null || _root.playername == "") {
		_root.specialmessages.gotoAndPlay(2);
	} else if (_root.playerbirth == null || _root.playerbirth == "") {
		_root.specialmessages.gotoAndPlay(16);
	} else {
		_root.nextFrame();
	}
}

Just some side notes:

|| 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.

And just because I am bored, I set up an example .fla that exports the error to a dynamic textbox when you hit the submit button.

Thank you verrryyryyryry much!!

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.

:sleep:

Glad your problem is solved :slight_smile:

Yeah, I figured outputting to a textbox would be better and easier :slight_smile:

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() :wink: