all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

Passwords for a game


Passwords for a game DarkVortex
2/26/2006 6:28:54 PM
flash actionscript:
I'm making a game and i want the player to be able to put in a password so
he/she can start from that level. You've probably seen this before. can someone
check my code, it doesnt seem to be working...

on (release, keyPress "<Enter>") {
if (password eq "train2") {
gotoAndStop("Scene 1", 3);
}
if (password eq "cheese") {
gotoAndStop("Scene 1", 4);
}
if (password eq "hamburger") {
gotoAndStop("Scene 1", 5);
}
}

Re: Passwords for a game pwiop
2/26/2006 11:23:07 PM
try this - and remember using scenes would sem to go against better practice
The code is placed in the root timeline NOT on the button (button instance
name "b1")
The input filed has an instance name of "my_input"

b1.onRelease = function() {
if (my_input.text == "train2") {
gotoAndStop("Scene 1", 3);
} else {
if (my_input.text == "cheese") {
gotoAndStop("Scene 1", 4);
} else {
if (my_input.text == "hamburger") {
gotoAndStop("Scene 1", 4);
} else {
if (my_input.text == "") {
my_input.text = "Please type in code";
}
}
}
}
};
Re: Passwords for a game DarkVortex
2/27/2006 9:36:30 PM
Re: Passwords for a game pwiop
2/28/2006 1:45:27 AM
http://www.nepeanmedia.com.au/flash/flas/hamburger.fla
Re: Passwords for a game I have no screen name
3/28/2006 6:37:38 PM
I just found this topic; I'm trying to solve the same problem.

The linked hamburger example is almost exactly what I need, but I'm still a
little new to Flash, so I have two questions.
1. is it possible to make the enter button on the keyboard initiate the "go"
button?
In other words, I want users to be able to type in the password and hit enter,
as an alternative to clicking the go button.
2. When the user encounters this login, they are looking at a browser with two
flash objects running in it. How do I make it so that the correct password will
clear out both of those Flash objects and load in a whole new page with a new
flash movie?

Re: Passwords for a game jollyguy998
3/28/2006 10:04:35 PM
I have no screen name:

1. For the answer for Question 1. Yes, its possible. You can copy and paste
this cope into your BUTTON ActionScript Panel.


on(keyPress "<Enter>") {
if(Key.isDown(Key.ENTER)) {
if (_root.my_input.text == "train2") {
gotoAndStop(2);
} else {
if (_root.my_input.text == "cheese") {
gotoAndStop(3);
} else {
if (_root.my_input.text == "hamburger") {
gotoAndStop(4);
} else {
_root.my_input.text = "Incorrect code - try again";
}
}
}
}
}


using the hamburger.fla example.

~jolly
Re: Passwords for a game I have no screen name
3/29/2006 1:27:18 PM
The enter button script works perfectly, thank you!

For the second part, we have reconfigured the architecture so it's not such an
issue, but I am still left with the issue which will come up again, of how I
can jump to a specified frame in a second movie.

Thanks!

Re: Passwords for a game I have no screen name
3/29/2006 2:04:42 PM
I just noticed my passwords are case-senstive. is there any way to make them not case-sensitive?
Re: Passwords for a game jollyguy998
3/30/2006 9:19:31 PM
make the password all lower case and you can do something similar to this.


var password:String = pass_box.text; // Setting the new
variable equal to the user input

if(password.toLowerCase == "teatime")
allow();
else
deny();
AddThis Social Bookmark Button