Learn how to use Adobe Flash with all the free tutorials. Game Making, Animating, Cartoon Design, Web Design and much more...
How to make a password
In this tutorial we are going to make an input text field where the user needs to enter a password in order to play the flash file.
This is really easy to do.
Begin by selecting the ‘text tool’, and in the property box at the bottom, make sure it is set to ‘dynamic text’, and the text alignment is set to ‘Align Center’.
Now at the top of the stage, draw out a large text field that will fit the text, ‘invalid password’ in it. In the property’s box of this text field, underneath where it says, dynamic text, there will be an empty box, in this box, insert the following, ‘wrongPassword’. Without the quotes!!!
This text box will be used to let the user know if they have entered an invalid password.
Using the ‘text tool’ again, set it to ‘input text’, in the property’s box, and insert a text field on the stage. (This is where the user will enter a password). In the property box, underneath where it says, ‘input text’, write ‘my_passWord’, without the quotes!!!
And next to where it says Var: write, ‘passWord’, without the quotes.
Now we will need to insert a button, for the user to click after they have entered a password. Somewhere on the stage, using the ‘oval tool’, draw out an oval, where you want the submit button to be.
Now select the whole oval, right click on it, and then go down to ‘convert to symbol’, and make it a button.
Now right click on the button, and select ‘actions’, insert the following code:
on (release) {
if (_root.passWord == "cjay" == true) {
gotoAndStop(2);
} else {
_root.wrongPassword.text = "Invalid Passord";
gotoAndStop(1);
}
}
In the first line of code:
‘(_root.passWord == “cjay” == true) {
Change ‘cjay’ to whatever you want the password to be.
When the button is released, it checks to make sure that the password entered is cjay, and if it is it will go to the next frame.
Else
The text box we made before called wrongPassword, will display, the text ‘Invalid Password’ and it will stay at frame 1.
Now right click on frame 1 in layer 1, select ‘action’, and insert the following code:
stop();
my_passWord.password = true;
This code tells flash that to stop on this frame, and that the text entered is to be displayed with asterisks, as this hides the password.
Now right click on frame 2 of layer 1, select ‘insert keyframe’, and delete everything off this keyframe.
On this new keyframe, using the ‘text tool’ set it to ‘static text’, enter some text like, ‘the password you entered was accepted’.
And that’s it for this tutorial.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment