Free Flash Tutorials

Home • Members Tutorials Forum iSnapChat Contact Us 

 


Flash Tutorials

   

Flash - Password Protect


022
Beginners
Flash Compatibility: MX          For Flash MX 2004 click here

Written by: Phil

Length: 1500 words

 

The aim of the tutorial is to learn 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.

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 form most peoples eyes.

 

Don't write in and ask me how to hack into a Flash file as I will not tell you and if I see any such postings on the forum I will delete them.

 

Cross Ref: There is an Intermediate tutorial on how to make a Flash Movie that has both a User Name and Password: User Names and Passwords

 

Example: Download the Flash file  Beg 022a

 

Try the following passwords:   go    private    letmein     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 and set up a small movie. Mine is 323 x 45 pixels.
  2. Select a background colour. Click OK
  3. Use the Text tool to type: Password >
  4. Use the Arrow tool 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 and drag a text box on stage.
    If you have dragged the text tool you should get a paragraph text box which has a square in the top right hand corner:
  2. Open the Property panel (Ctrl F3).
  3. With the text box still highlighted select: Input Text from the drop down menu .
  4. Select the font, font style, size and colour:





  5. Select: Left Justify   
  6. If your Property panel is in collapsed view, click on the down arrow in the bottom right corner of the Property panel to expand the panel. If you have an up arrow your panel is already expanded.

  7. For line type select: Password.
  8. Select: Show Borders Around Text.

  9. For Variable name type: password

    NB: Lowercase.



    Your Property panel should look like this.

Step three: Creating the Buttons

  1. Create two buttons. One with the word Enter on it and another with the word Retry (see the tutorial on how to create buttons).
  2. Place the button with the word Enter onto the stage in frame 1.

Step four: Private Frame

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


    In the time line you will get a flag: There is not enough space to see the frame label yet, but when you add frames the label will appear.

  6. Click on the Enter button and write down the x, y position from the Property panel.
  7. Delete the button: Enter
  8. Open the Library (Window > Library) and drag out retry button.
  9. Position the button in the same place as the Enter button. To do this use the x, y coordinates in the Property panel.

Step five: Wrong Frame

  1. Right click (Mac Control click) on frame 20 and select: Insert Keyframe

    You will now be able to see the 'private' label in the time line.

  2. Delete the text: This is private, it is not for you!
  3. With the Text tool type on stage: Wrong!
  4. With the Arrow tool click on frame 20 so that it is highlighted.
  5. In the Property panel, where is says <frame label> type: wrong
    NB: 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.
  6. Right click on frame 30 and select: Insert frame. 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. Right click on frame 1 in the Time Line and select actions.
  2. Select Normal Mode from the View Options button .
  3. Click on the Plus button .
  4. Select: Actions > Movie Control > Stop
    This stops the movie from playing when it first loads.
  5. Click on the Plus button .
  6. Select: Actions > Variables > set variable
  7. In the Variable Text field type: password
    Leave the Value option empty, this means that every time the frame loads it will clear any password that may have been typed previously.

    Your code should look like this:

    stop();
    password =
    "";

Step seven: Button actions - Enter frame 1

  1. Right click on the button called 'Enter' and select Actions.
  2. Click on the Plus button .
  3. Select: Actions > Conditions/Loops > if
  4. For the condition text field type: password eq "webwasp"
  5. Click on the Plus button .
  6. Select: Actions > Browser > getURL
  7. For the URL option type: http://www.webwasp.co.uk

    If someone types the password webwasp they will go to the web page www.webwasp.co.uk
  8. Click on the Plus button .
  9. Select: Actions > Conditions/Loops > else if
  10. For the condition text field type: password eq "private"
  11. Click on the Plus button .
  12. Select: Actions > Movie Control > goto
  13. Select the option: Go to and Stop
  14. For the Type option use the drop down arrow to select: Frame Label
  15. For the Frame option use the drop down arrow to select: private

    If someone types the password private they will go to the frame with the label 'private'.
    NB: You may have as many else if's as you want, each password taking you to a different frame or web page.
  16. Click on the Plus button .
  17. Select: Actions > Conditions/Loops > else
  18. Select: Actions > Movie Control > goto
  19. Select the option: Go to and Stop
  20. For the Type option use the drop down arrow to select: Frame Label
  21. For the Frame option use the drop down arrow to select: wrong

    This means that if none of the first conditions are correct, the user will be directed to the frame 'wrong'.
  22. Click on the first line of the actionscript: on (release) {
  23. Place a tick next to the option: Key press
  24. Press Enter on the Keyboard and you should see <Enter> appear in the box next to Key press tick.

    This means that when the user may press enter on the keyboard rather than using the mouse.
    NB: 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.

    Your script should look like this:

    on (release, keyPress "<Enter>") {
        if (password eq "webwasp") {
            getURL("");
        } else if (password eq "private") {
            gotoAndStop("private");
        } else {
            gotoAndStop("wrong");
        }
    }

Step eight: Button actions - Retry frame 10

  1. Go to frame: 10
  2. Right click on the button called 'Retry' and select: Actions
  3. Click on the Plus button .
  4. Select: Actions > Movie Control > Go to
  5. Click on the first line of the actionscript: on (release) {
  6. Place a tick next to the option: Key press
  7. Press Enter on the Keyboard and you should see <Enter> appear in the box next to Key press tick.

    Your script should look like this:

    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.

 

Please indicate what you thought of this tutorial 
10 is the best: 
10 9 8 7 6 5 4 3 2 1


58048 visitors to this page since Jan 04

Phil Schulz's Facebook Profile
Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend: Click here

 Top of Page HomeMembers Tutorials Forum iSnapChat Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.