Does anybody know how to make a user enter their name in a text box. I’ve tried if else on the enter button but that didn’t seem to work?
I think using a text box and a few if statements should do the trick.
Only continue playing (i.e. to the next frame) if the text box has a length greater than 1.
if(textfieldname.text == ""){
errorMsg.text = "Please Enter Your Name";
}else{
// code here
}
Try this:
labelFormat = new TextFormat();
labelFormat.bold = true;
labelFormat.color = "0x000066";
labelFormat.font = "_sans";
labelFormat.size = 9;
inputFormat = new TextFormat();
inputFormat.bold = true;
inputFormat.color = "0x666666";
inputFormat.font = "_sans";
inputFormat.size = 9;
goFormat = new TextFormat();
goFormat.bold = true;
goFormat.color = "0x666666";
goFormat.font = "_sans";
goFormat.size = 9;
_root.createEmptyMovieClip("nameBoxMC", 1);
with (_root.nameBoxMC) {
_x = 175;
_y = 150;
moveTo(0,0);
lineStyle(1, 0xCCFFFF, 100)
lineTo(200, 0);
lineTo(200, 100);
lineTo(0, 100);
lineTo(0,0);
createTextField("labelTXT", 1, 50, 35, 100, 15);
with (labelTXT) {
text = "Enter your name:"
setTextFormat(labelFormat);
}
createTextField("nameTXT", 2,50, 50, 100, 15);
with(nameTXT) {
text = "your name"
type = "input";
border = "true";
borderColor = "0x0066FF";
setTextFormat(inputFormat);
}
}
_root.createEmptyMovieClip("goMC", 2)
with (_root.goMC) {
_x = 325;
_y = 225;
moveTo(0,0)
lineStyle(1, 0xFFCCFF, 100);
lineTo(30, 0);
lineTo(30, 15);
lineTo(0,15);
lineTo(0,0);
createTextField("goTXT", 1, 6, 1, 20, 20);
with (goTXT) {
text = "GO";
setTextFormat(goFormat);
}
}
_root.goMC.onRelease = function() {
if (_root.nameBoxMC.nameTXT.text == "") {
return;
} else if (_root.nameBoxMC.nameTXT.text == "your name") {
return;
} else {
trace("You're In!");
}
}
You love using emptyMovieClips newhopekenny!!!
Just something I’ve noticed…
Why yes, but it’s the only way to programmatically create movieClips!
I love trying to do it all via AS, instead of ever touching the rectangle tool, or F8. It’s like a puzzle I know how to solve, I just have to figure out what pieces to use…