dcsimg
First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Alan Wisternoff | Website: http://www.buffoonbrothers.com

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.
» Level Intermediate

Added: 2007-02-03
Rating: 7.43 Votes: 23
(10 being the highest)
» Author
Cycling, snowboarding, flash creator extraordinaire.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.