Search tutorials
The Flash
You can make your flash file as simple or as complicated as you desire. You can look at my .fla if you need help but how your flash responds to the incoming variables is up to you. You do need some basic components to your flash file though.1.) Two input text boxes, one for the user to input a username and the other a password. They both need variable names of "username" and "pass". Note In my swf at the start of this tutorial I have 3 fields, an extra one to confirm the password. Adding this is entirely up to you.
2.) Two buttons, one for registering new username and password combinations and another for logging in after registration is successful. The login button needs at least this code
on (release) {
loadVariablesNum("login.php", 0, "POST");
}
The register button needs at least this code
on (release) {
loadVariablesNum("register.php", 0, "POST");
}
But there is other code as well that is not mandatory but quite important. Firstly you must limit the possible characters inputted. This code on the main timeline will deal with that.
usernew.restrict = "a-zA-Z0-9";
This restricts the character entry to the instance of usernew (don't forget to give your username input textbox an instance name (usernew) as well as variable name) to letters of the alphabet (lower and uppercase) and the 10 digits. Do this for the password input textbox also and give it an instance name.
Maximum number of characters can be controlled using the textbox properties but making sure the user enters in a minimum number of characters can be coded for on the register button using an "if" statement.
if(username.length >= 6 && pass.length >= 6){
loadVariablesNum("register.php", 0, "POST");
}else{
_root.words = "Username must have between 6 and 12 characters.";
}
assuming you have set the maximum number of characters to 12.
Also it pays to check that something has actually been entered in the textboxes during login. On the main timeline set
username="";
pass="";
Then on the login button put
if (username != "" && pass != "") {
loadVariablesNum("login.php", 0, "POST");
}else{
_root.words = "Please enter a username and password";
}
If you want to look extra smart in the login and register buttons under the loadVariables command add
words="Processing..."
or something similar. You will need to add a dynamic textbox with the variable name, "words" to display all the feedback, both from the flash buttons as well as the php file. Finally check out the full working version at My Website and if you want to contact me use the flash form there also.