
Originally Posted by
evan
I want to create a text field, where the user has a password, upon verefication it proceeds to either go to a url or play a swf(I know how to do that part.)
I just need a simple explanation or a tutorial that talks about verifying user input such as id and pasword.
What level of user authentication are you wanting to do here? Is this linked to a user database (e.g. mySQL)?
If so, you're going to have to use a combination of PHP and AS for it to work. Flash can't directly connect to MySQL, but it can communicate with PHP. So, the workflow here would be to send whatever is entered through the input field to a PHP script that would authenticate the user and then reply back to Flash with some sort of signal (probably through a variable).
If it's just a matter of a few usernames that you want to hard code, then we're just talking some basic conditionals:
AS3:
Code:
submit.addEventListener(MouseEvent.CLICK, authenticate);
function authenticate(e:MouseEvent):void {
if(username.text == "John") {
if(password.text == "Doe") }
gotoAndPlay("successful_login");
}
else {
status.text = "Incorrect Password";
}
}
else {
status.text = "Incorrect Username";
}
}
AS2:
Code:
submit.onRelease = function() {
if(username.text == "John") {
if(password.text == "Doe") }
gotoAndPlay("successful_login");
}
else {
status.text = "Incorrect Password";
}
}
else {
status.text = "Incorrect Username";
}
}
username and password are instance names for input fields. status would be another dyanamic text field that could display errors. Of course, if you're going to hard code more, you'll probably want to loop through an array or use switch/case syntax instead of repeating code blocks.
Let me know if there is server-side scripting involved. I'll post an small example of how that's done if you need.
Bookmarks