NOTE: This method of protection isn't very reliable! I will not be responsible for anything that happens to your website, as this can easily be hacked!
Okay, with that out the way lets get this show on the road. I won't be including images with this one either, merely for simplicity but (again) if you do need them, please make a request and I will oblige (being the nice alien that I am)
Okay, we are going to make a simple password protection, it will mainly be actionscript - but don't worry this is a beginners tutorial, so its for any one in the family!
Step One: Setting the Scene
Okay, first of all get some dimensions and a background colour down, I chose 400x50 with a nice black background, you can choose whatever you like.
Step Two: Introducing the Input Box
For this tutorial, the main object will be the input box where our (potential hacker) user will type his/her password.
We will need 4 Layers! First of all rename the unoriginal Layer 1 to something like Text Box, create 3 more layers called: Button, Frames and ActionScript
With that out of the way, go back to the Text Box layer (frame 1) and select the Text Tool (T) now, draw a long, thin text box on your stage. Make sure that in the properties window(CTRL+F3) you have the text box type as Input Text (this is important) also for a more professional touch click the little button (on properties window) to the left of the Var: field this will show a border around the textbox! Finally give our text box an Instance name this is under the drop-down menu with Input Text written on. I will call mine pass_word.
Step Three: Buttons! Buttons! Buttons!
Okay, first of all we need a submit button to submit the password form! Switch over to the Button to create our button. I just used a Static Text field with Submit typed in. You can have anything, nevertheless this must be converted to a button, hit F8 while your button is selected and enter the following properties: Name: Submit, Behaviour: Button, Registration: Central and hit OK.
You can add rollovers...a hit or whatever within the button time line (I assume you know how to do that - as you should know the basics by now!) Once you have finished playing around with your button, align it on the stage so it fits in nicely with your password field.
Step Four: Inserting Frames
Ok, now we need to switch over to the Frames layer - this is an important layer, as here we will decide where to take our users once they have submitted there password.
Select frame 1 of the layer and in the properties window you should see a input box that says <Frame Label> (or something similar)
In here I am going to enter password and hit enter to confirm.
Now select frame 2 of the same layer, and hit F6 to insert a keyframe. You will (again) notice the <Frame Label>. In here, type knowflash and hit enter to confirm. Once again do the same process for frame 3 this time making the <Frame Label> knowphotoshop and finally, do the same to frame 4 this time calling it wrong.
Now, head back to Frame 2 of this layer, and delete everything on the stage (don't worry!) Now on this layer I am going to create some static text with the words Welcome to KnowFlash.com! (if you are confused at this point why we are doing this - don't worry all will be revealed)
Now on Frame 3 of this layer again delete everything on the stage, but this time I am going to insert some static text saying Welcome to KnowPhotoshop.com!
On the final and 4th frame, things get a little different, this time make the static text say WRONG!
Make sure your static text is all aligned neatly and we will proceed to the Actionscript.
Step Five: ActionScript!
Proceed to the ActionScript layer, this part is simple, we only require one line of coding. With Frame 1 of this layer selected hit F9 to open up the Actions panel.
Now, Copy and Paste/ type this:
| Code: |
| stop(); |
Now, hit F9 once again to close the panel.
Step Six: Configuring Buttons!
Okay this is the final part of the tutorial! (and the largest part of Actionscript)
Go back to your Button layer and ensure that only the Submit button we created is selected. Next, hit F9 on the button to bring up the Actions Panel once more.
Copy and paste/type the following code:
| Code: |
| on (release) { if (pass_word.text eq "knowflash") { gotoAndStop("knowflash"); } else if (pass_word.text eq "knowphotoshop") { gotoAndStop("knowphotoshop"); } else { gotoAndStop("wrong"); } } |
Now hit F9 to close the Actions Panel.
Press CTRL+Enter to test your movie.
Note: Try the passwords: knowflash, knowphotoshop and try something like hfkdjfhs
Actionscript - Explained!
Okay this is fairly straight forward,
The first line tells flash what to do when the button is released - in this case there are other parameters to consider before flash knows exactly - The next line says "If the users types knowflash into the password field goto the frame knowflash" the next else if statement says, "If the user types knowphotoshop into the field goto knowphotoshop" and the final part of the code means "otherwise...goto the WRONG! page"
I hope it is fairly straight forward to understand, and no doubt you can develop it!
Again, if you want images, let me know or contact me on MSN Messenger at ben@xeroc.info for more individual and detailed help!
_________________
| Code: |
| <?php echo "I am Thor Supreme Commander of the Asgard Fleet"; ?> |
discuss this topic to forum
