00:00
00:00
Newgrounds Background Image Theme

809118566 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS:Component Password

1,250 Views | 4 Replies
New Topic Respond to this Topic

AS:Component Password 2005-11-07 00:10:08


[b]This coding may require Flash 8[/b]

This is sort of an advanced password tutorial,mostly because components were used instead of plain buttons.So basically,you'll learn about both components and password.

Actually,you will only be using 2 components.The Button component and the Text Input component.Let's start.

First of all,view a sample before we go into the coding.

Sample Password.

Ok,first before anything,open up the component window by going to the top of the screen and selecting Window>Components,or by pressing Ctrl+F7.

Click where it says "User Interface" on the component screen.Drag 2 "Button" components onto your stage.

Give the first button the instance of "con".Also,press the tab that says "Parameters".Where it says "label",type in "Continue",or whatever your going to use,such as "Enter" or maybe "Move on".

Give the second button the instance of "ch",which means "click here",which is for if you type in a wrong password.Go to that button's parameters and give it a label name.I used "Click here".You could also use "Clear",because this button is supposed to clear the screen.

Now,still having the component box up,scroll down until you find "TextInput".Drag 2 of these onto the stage.

The first bar needs to be aligned next to the "Continue" button,like in the sample.The second one needs to be aligned the same way,but then dragged down a little bit,like in my sample.

Now,the first bar gets the instance name of "box".You do not need to edit the parameters in this text box.Now,give the second box the instance of "ps".This box you need to edit the parameters.Go to the parameters tab and select "editable".A scroll box appears.Change it to "false".This will make it so people cannot edit the textbox.Do not change this on the first box,or typing in a password won't work.

Ok,I'm pretty sure we can move on to the coding now.I'm sure you know you need a stop(); action on the frame.

BEFORE WE MOVE ON,REMEMBER,ALL CODING GOES INTO THE FRAME THAT THESE OBJECTS ARE ON.

First of all,we need to hide the "clear" button,the one named "ch".

ch._visible = false;

This will make the button invisible.

Next comes naming the of the output text box.

ps.text = "undefined";

Now,we go onto some bigger coding.It is explained along the way.

con.onPress = function() {
//This is how you make a button with movieclips.
if (_root.box.text == "hi") {
_root.gotoAndStop(2);
//The 'if' of the boxes.'box' is selecting the first text box that
//was used and .text == "hi" is checking to see if
//the text box has the word 'hi' in it.Change 'hi'
//to whatever you want your password to be.
//This part will also go to the frame specified.Change '2' to
//the specified frame.
} else {
_root.ps.text = "In-Correct";
ch._visible = true;
}
//This is the 'else'.This 'else' is watching to see
//if 'hi' is not entered into the first text box.
//ps.text = "In-Correct"; changes the output text
//to 'In-Correct',telling the person that their
//password entered is wrong.ch._visible = true; makes
//that little 'clear' button visible again,allowing the
//person to clear their output history.

That is only the first part.Here is the second part...

ch.onPress = function() {
//This,once again,is the movieclip button code
ch._visible = false;
ps.text = "Undefined";
box.text = "undefined";
};
//ending the code,here is the coding for the clear button.
//ch._visible = false; will make the button invisible
//after being pressed.ps.text = "Undefined" will change
//the output box text back to "Undefined".

Now,to end this tutorial,I will post the full code.

ch._visible = false;
ps.text = "undefined";
box.text = "undefined";
con.onPress = function() {
if (_root.box.text == "hi") {
_root.gotoAndStop(2);
} else {
_root.ps.text = "In-Correct";
ch._visible = true;
}
};
ch.onPress = function() {
ch._visible = false;
ps.text = "Undefined";
box.text = "undefined";
};

This is somewhat different than the other tutorial made,because it's using components instead of whatever else.


wat

Response to AS:Component Password 2005-11-07 03:22:02


Sorry,I forgot to change the HTML code to the NG BOLD format on the top of the screen.


wat

Response to AS:Component Password 2005-11-07 13:21:26


At 11/7/05 03:22 AM, -Thomas- wrote: con.onPress = function() {

Rofl, do you know what "con" means in French? It's like "stupid" :P


BBS Signature

Response to AS:Component Password 2005-11-07 17:40:47


Lol,that's nice to know.

You can change that if you find it offensive or anything...all I was doing was abbreviating(if that's spelled right)

:p


wat

Response to AS:Component Password 2005-11-07 18:04:01


Very cool, very cool :P.


BBS Signature