PDA

View Full Version : Set a name in a game



dudeman001
September 24th, 2006, 07:04 PM
I'm trying to get it so you can type your name in a input text box on the first frame, then you go on to the second frame and it will say "Hello name"

If anyone could help, that would be greatly appreciated.

Templarian
September 24th, 2006, 07:16 PM
Why use frames, your just making it harder on yourself.

Create an input field (instance "input")
Create a dynamic field (instance "output")
Create a button (instance "btn")



//place this on the first frame (click the first frame and paste it in the as box).
onEnterFrame = function(){
if (Key.isDown(32)) {
this.output = "Hello " + this.input + "."
}
}

Thats from memory so it could be wrong but should work.

//edit,
To make your game learn about arrays, logically you can figure out why you will need arrays.

dudeman001
September 24th, 2006, 07:32 PM
I don't really get what you mean, try and perform what you're talking about on this.

39112

Templarian
September 24th, 2006, 08:42 PM
www.templarian.com/misc/kirupa/here.flas (http://www.kirupa.com/forum/www.templarian.com/misc/kirupa/here.flas)
(my server won't let me upload a .fla lol so just delete the "s" from the end when your done).
www.templarian.com/misc/kirupa/here.swf (http://www.templarian.com/misc/kirupa/here.swf)

like this?

Lemuel
September 24th, 2006, 08:53 PM
THis works too.

Uses your provided example.

Hope it helps.

-Lem

http://albertaintegrated.com/game2.zip

dudeman001
September 24th, 2006, 09:05 PM
Thank you very much, that's exactly what I wanted.

dudeman001
September 24th, 2006, 09:07 PM
heh.. do you have any idea how I could be able to type like good and press enter and it would like be added?

Lemuel
September 25th, 2006, 10:46 AM
Sure.

Make a Input field

Give it a simple variable name like inputText

Make a button

Give the button this action


on (keyPress "<Enter>") {
gotoAndStop("Target_Frame")
}

And then on the target frame have the actions required for displaying the text.

Or instead of having the button send you to another frame you could setup the button with the required actions to display the new text in the spot you need it


on (keyPress "<Enter>") {
displayBox = inputText
}


Hope that helps

If not feel free to ask more questions.
I happen to like helping people with these kind of problems when I can.
Especially since I end up relying on forums alot myself for problem solving in areas I haven't touched or learned well enough yet.

-Lem

dudeman001
September 25th, 2006, 07:32 PM
Thank you very much, now I have the basics for everything I need, once again, thank you so much!

dudeman001
September 25th, 2006, 08:09 PM
it seems that with that code, when I have multiple ways it could go, it doesn't matter what I type, it will go to like a random frame..

heres the source

39123

If you could maybe tell me what's wrong, that would be awsome.

KIERIOSHIMOTO
September 25th, 2006, 08:22 PM
Here's something i tried a while ago that might help you out.

KIERIOSHIMOTO
September 25th, 2006, 08:22 PM
You will need to store responses in an array.

dudeman001
September 25th, 2006, 08:33 PM
Yes, but what i'm trying to do is have a different response acording to different things I say.

KIERIOSHIMOTO
September 25th, 2006, 08:35 PM
Arrays.

KIERIOSHIMOTO
September 25th, 2006, 08:37 PM
Just do what i did in my example all over again, but instead of type "hi" or "hello" ask a question. You will most likely need an array if you want a random answer according on what you say anyway.

dudeman001
September 25th, 2006, 08:57 PM
Well, I'm not very good with arrays, that's why I was avoiding it, but if that's what I have to do, then i'll learn.

dudeman001
September 25th, 2006, 09:33 PM
could you maybe supply me with the code I need to put on the button to make it so if I type good, it will go the the good page, and bad it will go to the bad page? If so, i'd really appreciate it.

//EDIT: I can get it so it goes to the good page, but if I type bad, it goes to the good page..

dudeman001
September 26th, 2006, 11:02 PM
any one? at all?