
Page 1 of 1
Perlaki
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
View all articles by PerlakiDifficulty Level: Beginner
Requirements: Flash 5 or higher
Download FLA
This is a simple password file, ideal for business clients' access, or just friends to view personal pages.
You can set any number of passwords to launch any number of pages, or go to another part of the flash movie.
I have set this movie to accept "jokes", "stories" and "pictures" to load a new page, and "private" to go to another part of the movie. TRY IT! You can either press the 'Enter' button on the screen or on your keyboard.
Create a movie clip (Ctrl+F8) called "passwordMC", and we'll have all the workings in it. This makes it easier to move around later on in your design.
Edit this MC and set up 2 layers, and in layer1, frame1 have:
1. input text box with the variable name "password",
2. an enter button
3. add the stop (); command on the keyframe.
On layer2, frame10, call frame label "error"
On layer1, frame10, have a retry button.
Now to add the code.
On the enter button:
on (release, keyPress "<Enter>") {
if (password eq "pictures") {
getURL ("pictures.htm", "_blank");
} else if (password eq "jokes") {
getURL ("jokes.htm", "_blank");
} else if (password eq "stories") {
getURL ("stories.htm", "_blank");
} else if (password eq "private") {
tellTarget ("_level0") {
gotoAndStop ("private");
}
} else {
gotoAndStop ("error");
}
}
on (release) {
gotoAndPlay (1);
}
The last step is to have the private section of the movie.
Go back to the base timeline of Scene 1, where the password MC is placed (this is level 0). Then add a new blank keyframe further along the timeline (say frame 10) Give this keyframe the label "private". This is where you place your top secret files for 007 to access. Also, because the enter button says 'gotoAndPlay', you will need a stop command here, or change the button command to 'gotoAndStop.
EXPLAIN!! Well, when the user presses the "enter" button, the code checks to see if it recognizes the password e.g."pictures". If it does then the next line is read, "getURL ("pictures.htm", "_blank");" otherwise it goes to the next line and so on, until it gets to the "else" and then if nothing is recognized, then it carries out the final command - gotoAndStop ("error");
For the "private" password, the code controls the timeline on level 0 by the tell target command:
tellTarget ("_level0") {
gotoAndPlay ("private");
}
It's simple, yet effective. Enjoy!!
Spread The Word
Related Articles
4 Responses to "Password protected pages" 
|
said this on 11 Apr 2008 6:22:26 PM CDT
Great tutorial, however,
|
|
said this on 07 Oct 2008 11:04:42 AM CDT
This is a basic authentic
|
|
said this on 31 Oct 2008 11:12:20 PM CDT
Has anyone tried this? F
|
|
said this on 01 Jan 2009 8:38:24 PM CDT
This is a great guide; my
|


Author/Admin)