Custom Search

Tuesday, December 11, 2007

Basic Flash Password Protection Parts 9,10

Part 9

Now we’ll need to write the actual script that compares the value of the input, but first we’ll need something to attach it to. Create a button near to your password input field; you can add the text “Submit” to let the user know that it’s clickable, or hide it by making it the same color as your background or turning it into an invisible hotspot button.

Right-click on the button and open the Actions panel.


Part 10

on (release, keyPress “”) {
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).



No comments: