1. Home
  2. Computing & Technology
  3. Animation

Basic Flash Password Protection

By , About.com Guide

10 of 10

on (release, keyPress “<Enter>”) {
if (password eq “aikotoba”) {
gotoAndPlay(2) ;
password = “”;
} else {
gotoAndPlay (3) ;
password = “”;
}
}

That looks like a lot, but it’s not. It’s an function that tells Flash to use an if statement when the mouse clicks the Enter key is pressed.

The if statement checks to see what the characters entered for “password” are, and compares them to a value set by you: the actual correct password, inside the quotes. If the two are the same, then Flash will go to the “access granted” frame/scene (frame two, for me). If not, the else statement redirects to the “wrong answer, try again” screen. In both instances, the password is reset to nothing, so that it’s not carrying the entered string around.

In mine, “aikotoba” is the correct password; if the user enters “aiko”, then password=”aiko”. Flash asks itself, “does aiko equal aikotoba?” and, when the answer is no, shunts them off to the “wrong answer” screen.

Note that the if statement uses eq instead of = to see if they’re the same; this is because it’s comparing two character strings, and not comparing an actual value.

Click here to return to the blog post and try it out.

Explore Animation
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. Basic Flash Password Protection

©2009 About.com, a part of The New York Times Company.

All rights reserved.