First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Juan Rosa

Password Protection in Flash

One day I was searching for a way to protect part of my movies so that only does with the password could see my secret area within the movie. I search all over the net for a good password protection system, but couldn't find what I was looking for, so I had to build my own.

I learned in sesame street that it's good to share with your friends. So here I present to you my password protection system.

Note:This password system will only protect the movie until someone takes your SWF and hacked into its actionscript. there are many utilities to do so

Here we go

Movie Setup

Create 4 Layers. Name the first layer "Actions", the second layer "Validate", the third layer "inputform" , and the fourth layer "Text"

The TextField

In the "inputform" layer create a Textfield then open the text options panel (ctrl + T) click on the Text Options tab and set the text type to 'input', the line type to 'password', check 'Border/Bg' and give it a Variable name "pw".

The Button

Create your own or drag one from the Common Libraries (Windows/Common Libraries/buttons). place it in the "inputform" layer

The Actions script

In the "Actions" Layer first frame place this ActionScript:


Place this ActionScript in the button:


on (release) {
    if (_root.pw == null or _root.pw == "") {
        gotoAndStop (2);
    } else if (!(_root.pw == "pass")) {
        gotoAndStop (3);
    } else {
        gotoAndStop (4);

The Layers

In frame 2 of the "Text" layer create a static textfield and type (Please enter Password).
In frame 3 place another textfield and type (Wrong Password).
In frame 4 type (Welcome!! you entered the correct password).
And know for the cool part...

The Validation

In frame 4 of the "validate" layer create a circle or something then convert it to a movieclip (F8) After you create your movieclip Place it outside of the stage then right click on it and select Actions from the menu and put this ActionScript into the movieclip:

onClipEvent (enterFrame) {
    if (!(_root.pw == "pass")) {

This is the ActionScript that prevents user from going into your protected area without the password. They can get into your protected area just by going forward with the control menu commands or by (Ctrl + right arrow key)


Make sure that frame 1 of the "inputform" layer expands from frame 1 to 3 only.
Make sure that the movieclip in the "validate" layer is at frame 4
Now Test your movie (Ctrl + Enter)


» Level Basic

Added: 2002-08-18
Rating: 6 Votes: 13
(10 being the highest)
» Author
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
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.