Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Flash Tutorials How to Create an Easy Login System

How to Create an Easy Login System


If you're new to variables or functions in flash, pelase read the tutorials about them in the tutorials archive.

Create a new flash document (Ctrl - N).

Rename layer 1 to "actions". This is where we'll apply the script.

image 1

Create a new layer and name it "input_text". This is where we'll put the username and password text boxes.

image 2

Create another layer. This time name it "static_text". This is where we'll put the login success or failure messages and so on.

image 3

In the "static_text" layer, create three static text boxes just like I've done:

image 4

Select the "input_text" layer and create an "input text" field. To set the text field to "input text", just do like this:

image 5

Make sure that you set the text field border to on. You can find the border button in the bottom right corner of the image above.

Before you continue, you may want to lock the "static_text" layer.

Create a text field as shown below:

image 6

Select the text field you just created and set the variable name to "user_input". This is done in the properties tab as shown below:

image 7

Repeat the process to cerate a password field. Just make sure you select "Password" as shown below:

image 8

Select the newly created text field.

image 9

Set the variable name to "pass_input".

Unlock the "static_text" layer and lock the "input_text" layer.

In the "static_text" layer, insert new keyframes at frame 2 and 3. Delete the content in the newly created frames.

image 10

Select the "actions" layer and insert keyframes at frame 2 and 3.

Select frame 1 in the "actions" layer and open the "Actions" panel.

image 11

In the first line write "stop();".

image 12

In line 2 and 3 we set the username and password variables to zero, or empty. Because we want the user to input the username and the password, not the program.

image 13

Let's create the login button.

Close the actions panel and select the "static_text" layer.

Select the "Login" text. Right click on it and select "Convert to symbol".

image 14

Make it a button and set the name to "login_button".

image 15

Select the newly created button.

image 16

Set the instance name to "login_button" in the properties panel.

image 17

Select frame 1 in the "actions" layer and open the actions panel again.

In line 4 we create the onRelease function. This function will determine what will happen when we push the login button.

image 18

As you can see, the first word is the instance name of our login button. So this function will be applied to it.

If you don't know what I'm talking about here, please read the Intro to functions tutorial.

image 19

As you can see, I've added a whole bunch of words within the onRelease function. If you're not completely new to Action Scripting, this should look familiar.

But if you're not, I'm going to explain the basics here.

We begin by asking a question. An "If" question. It's basically like this: If the username is User1 and the password is mypassword, then goto and stop at frame 2. If it isn't, then goto and stop at frame 3.

So right here we set the username to "User1" and the password to "mypassword". So that's the values the user has to enter to gain access to frame 2. You may of course change this to whatever you want.

Having done that, let's move on.

Close the actions panel and select frame 2 in the "static_text" layer.

Create a logged in message or something that confirms that the login process was successful.

I created a static text field saying "You're logged in!".

image 20

Do the same thing at frame 3, just make it a login failed message.

How to Create an Easy Login System

And that's it! You can test the movie (Ctrl-Enter).

If you type in "User1" as username and "mypassword" as password you will get to frame 2. Anything else will send you to frame 3.



Author's URL: Stian Bakkane
Final results of our readers
New!
Passed through all the steps? Share your result!
Your result will be premoderated.
Please make sure you choose the right image.
 
 



Captcha

*Required fileds
Our Flash tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website. More Flash Tutorials: Featured Materials | Fresh Materials | More Flash Tutorials at FlashPerfection.com

Reader's comments
comments Name November 22, 2011 says:
This may be the reason why this is not working. This was made with by replacing the "gotoAndStop(3)" line with a trace function.

User Name = <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">u</FONT></P></TEXTFORMAT>
Password = <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000" LETTERSPACING="

Reply
comments Name November 22, 2011 says:
the "u" is just an example letter, also there is piece missing on the next line, here it it
"LETTERSPACING="0" KERNING="0">s</FONT></P></TEXTFORMAT>"
the "s" is the same as the "u", just an example

Reply
comments Name November 22, 2011 says:
just found the reason why it is not working.
The "Auto kern" function must be turned off, it's on by default!
sorry about the 3 posts over such as small time lol

Reply
comments KTINE June 20, 2011 says:
it always goes to frame 3 for me too! what should i do? Pls. reply!
Reply
comments KTINE June 20, 2011 says:
it always goes to frame 3 for me too! what should i do? Pls. reply!
Reply
comments A GUY March 05, 2011 says:
it always goes to frame 3 for me!!
Reply
comments Pyaie February 01, 2011 says:
I also it's always goes to frame 3 for me.... what should i do?
Reply
comments anonymous December 30, 2010 says:
How do you create multiple passwords and usernames? That would really help.
Reply
comments Name October 18, 2010 says:
what program is this
Reply
comments Jon September 02, 2010 says:
When I test this It always says these errors:
Scene=login, layer=static_txt, frame=1, Line 1 Statement must appear within on handler
Scene=login, layer=static_txt, frame=1, Line 2 Statement must appear within on handler
Scene=login, layer=static_txt, frame=1, Line 3 Statement must appear within on handler
Scene=login, layer=static_txt, frame=1, Line 4 Statement must appear within on handler
PLEASE HELP!!!!!!!!!!!!

Reply
comments somone August 21, 2010 says:
it always goes to layer 3 for me T.T what to do?
Reply
comments a April 29, 2010 says:
Hey, great tutorial but you forgot to say that you should add "stop();" in frame 2 and 3
Reply
Add comments to "How to Create an Easy Login System"

Captcha