Her

Home Flash & Swish Flash Tutorials Password Protect

Password Protect

Author: Phil Author's URL: www.webwasp.co.uk More by this author

This tutorial shows you how to create an input box which the user types a password. If the password is correct the user goes to a new frame in the Flash movie or a new web page. Using password protection in a file gives more security.

Important Note: Never use Flash Password protection for highly sensitive material. It is ok for low security material only. Flash files can be hacked into (for people who are into that sort of thing). Bare in mind that the vast majority of people on the net will have no idea of how to hack into a Flash file (or interest) and so information stored behind the password is quite safe from most peoples eyes.

There are Flash encryption programs which you can use to lock you Flash Movies and make them much more secure. These cost about $50.

image 1
Click to enlarge

Try the following passwords:   webwasp    forum     private      please

You can use either the Enter button above or Enter on your keyboard.

Step One: Setting up the Document

  1. Go to Modify > Document
  2. Set up a small movie. Mine is: 323 x 45 pixels
  3. If you wish select a: Background Colour
  4. Click: OK
  5. Use the Text tool image 2 to type: Password >
  6. Use the Selection tool image 3 to deselect the text you have just typed by clicking anywhere on the page away from the word you have just typed.

Step Two: Create the input box

  1. Select the Text tool image 2
  2. Drag out a: Text Box

    If you have dragged the Text tool you should get a paragraph text box which has a square in the top right hand corner:

    image 5

  3. If the Property Inspector is closed, open it: Window > Properties (Ctrl F3)
  4. With the text box still highlighted select: Input Text

    image 6

  5. Select the font, font style, size and colour.

    image 7

  6. Select: Left Justify    image 8
  7. If your Property Inspector is in collapsed view, click on the down arrow image 9 in the bottom right corner of the Property Inspector to expand the Inspector. If you have an up arrow image 10 your Inspector is already expanded.

  8. For line type select: Password.
  9. image 11

  10. Select: Show Borders Around Text. image 12

  11. For Variable name type: password

    image 13 Note: Type the Variable name in the Lowercase.

    Do not mix up Variable Names and Instance Names as they are not he same.
    Your Property Inspector should look like this. (Click to enlarge)

Step three: Creating the Buttons

  1. Create two buttons. One with the word Enter on it and another with the word Retry

          Cross Ref: See the tutorial on how to create buttons

  2. In Frame 1 place the: Enter Button

Step four: Private Frame

  1. Right click (Mac Ctrl click) on frame 10 and select: Insert Keyframe
  2. Delete the: Text Box
  3. With the Text tool image 2 type on stage: This is private, it is not for you!
  4. With the Selection tool image 3 click on frame 10 so that it is highlighted (it goes black).
  5. In the Property Inspector, where is says <frame label> type: private

        image 16

       In the Timeline you will get a flag like this:  image 17

       There is not enough space to see the frame label yet, but when you add frames the label will appear like this:   image 18

  6. Click on the Enter button.
  7. Write down your X, Y position from the Property Inspector.

        image 19

  8. Delete the button: Enter
  9. Open the Library: Window > Library (F11)
  10. Drag out the button: Retry
  11. Position the button in the same place as the Enter button.

        Note: To do this use the x, y coordinates in the Property Inspector.

Step five: Wrong Frame

  1. Right click (Mac Ctrl click) on Frame 20 and select: Insert Keyframe

    You will now be able to see the 'private' label image 20 in the Timeline.

  2. Delete the text: This is private, it is not for you!
  3. With the Text tool image 2 type on stage: Wrong!
  4. With the Selection tool image 3 click on: Frame 20
  5. In the Property Inspector, where is says <frame label> type: wrong
  6. Note: Type in lowercase. We will refer to these frame labels in the actionScript, and as action script is case sensitive, so the script must match how it is typed here.

  7. Right click on frame 30 and select: Insert Frame

               Note:
    This allows you to see the label: wrong

    You have now finished laying out the visible objects and labels. The only thing left to do is the actionscript.

Step six: Frame actions - frame 1

  1. Select the: Frame 1
  2. If the Action panel is closed, open: Window > Development Panel > Action (F9)
  3. Place the following ActionScript :

    stop();
    password = "";

Step seven: Button actions - Enter frame 1

  1. Select: Frame 1
  2. Select the button called: Enter
  3. If the Action panel is closed, open: Window > Development Panel > Action (F9)
  4. Note: This will not work in Test Mode as Enter has a preset meaning: Play the movie. But it will work when the movie is published to a web page.

  5. Place the following ActionScript

          on (release, keyPress "<Enter>") {
              if (password eq "webwasp") {
                  getURL("http://www.webwasp.co.uk");
              } else if (password eq "forum") {
                  getURL("http://www.webwasp.co.uk/forum");
              } else if (password eq "private") {
                gotoAndStop("private");
              } else {
                  gotoAndStop("wrong");
              }
          }

Step eight: Button actions - Retry frame 10

  1. Go to frame: 10
  2. Select the: Retry Button
  3. To select the Action Panel: Window > Development Panel > Action (F9)
  4. Place the following ActionScript on the button:

    on (release, keyPress "<Enter>") {
        gotoAndStop(1);
    }

Step nine: Button actions - Retry frame 20

The script for Frame Retry Button on Frame 20 is identical to that of the retry button in frame 10.

Your movie should now be finished.

Security

Important: When you go to publish your movie select the following settings: File > Publish Settings > Flash > Compress Movie (Flash MX only). This makes it slightly harder for a hacker to crack the password.

Note: If the password takes the user to a new web page, that page is not necessarily secure but hidden. For high security material never use Flash to protect your data or other material.