> > Tutorials > T1021

Create password field and protect part of the Flash file.



Create edit text field with “password” attribute. Add “OK” button and define button’s “OnClick” event.

Minimum Flash Designer version: 5.0.22

  1. Launch Flash Designer and create blank animation. Set frame size (“Frame” > “Frame Size”) to 300 x 200.
  2. Make the first frame static, choose “Frame” > “Frame Delay”, check “Stop” and click OK.
  3. Choose “Edit Field” tool and draw the edit field. Choose “Item” > “Edit Properties”. Check “password” option and uncheck “HTML” then click OK.
  4. Choose “Button” tool and draw a button. Choose “Item” > “Edit Properties”. Change button text to “OK”, click OK to confirm.
  5. Make sure the button is selected and choose “Action” > “OnClick”. Put the following code, select enter key as the “Shortcut” and click OK:
    if(Edit1=="password")     gotoAndPlay("Frame 3"); // password OKelse    gotoAndPlay("Frame 2");  // wrong password


  6. Choose “Frame” > “Insert” to add “Frame 2” and “Frame 3”.
  7. Go to Frame 2 and add “Wrong Password” text with the “Text” tool. Choose “Frame” > “Frame Delay”. Uncheck “Stop” and put 1 second. Click OK. Choose “Frame” > “Loop” and choose “Frame 1”, click OK.
  8. Go to Frame 3 and add “Password OK” text with the “Text” tool.
  9. Press F9 to preview the animation.

Double password option

If you wish to use more than one password and create different secure areas use the following method:

double password

  1. Create 4 frames (“Frame 1”, “Frame 2”, “Frame 3” and “Frame 4”)
  2. On Frame 1 draw edit field (Edit1) and OK button
  3. OK button “OnClick” action:
    framelabel = "Frame 2"; if(Edit1=="password1") framelabel = "Frame 3";if(Edit1=="password2") framelabel = "Frame 4";gotoAndPlay(framelabel);
  4. Put on Frame 2 “Invalid password” text
  5. On Frame 3 put “Content 1” text, on Frame 4 put “Content 2” text, set Frame 3 and 4 duration to “Stop”
  6. Set Frame 2 loop to “Frame 1” (select “Frame 2”, choose “Frame” > “Loop” command and choose “Frame 1” as the target)

Download source project

get flash