Be a Supporter!

Input fields

  • 160 Views
  • 3 Replies
New Topic Respond to this Topic
sonic180
sonic180
  • Member since: Feb. 4, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Input fields 2011-07-16 01:35:30 Reply

Hey, so I just figured out how to do input fields that you can type in. I was just wondering how you would make a quiz like game. You type in your answer in the field, and then press a button and then it checks to see if it's right. If it is, go to the next frame. Would I have to learn about strings for this? Even if you just point me in the direction of a tutorial, it would be greatly appreciated. Also, I would like for this to be in AS2. I just don't like using AS3 when I don't have to.

SethFx23
SethFx23
  • Member since: Jul. 13, 2011
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Input fields 2011-07-16 02:59:21 Reply

Well you could come up with the question. And in the input field you could check. Do an if statement. Like if it is (correct answers) gotoAndStop (nextFrame) else "come up with something when they get it wrong"

FlyingColours
FlyingColours
  • Member since: Jul. 3, 2011
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to Input fields 2011-07-16 09:51:22 Reply

At 7/16/11 01:35 AM, sonic180 wrote: Hey, so I just figured out how to do input fields that you can type in. I was just wondering how you would make a quiz like game. You type in your answer in the field, and then press a button and then it checks to see if it's right. If it is, go to the next frame. Would I have to learn about strings for this? Even if you just point me in the direction of a tutorial, it would be greatly appreciated. Also, I would like for this to be in AS2. I just don't like using AS3 when I don't have to.

I gave the field an instance name of 'field', the variable that holds the answer 'rightAnswer' and the button 'button'. I think this should be right; I'm quite new to Flash though, so I might make a mistake somewhere.

field.onRelease = function(){
var answer:String;
answer = field._text;
if (answer == rightAnswer){
nextframe();
} else {
tryAgain();
}
}

Alternatively, you can put this code in the button, although this makes proofreading the code frustrating:

on(release){
var answer:String;
answer = field._text;
if (answer == rightAnswer){
nextframe();
} else {
tryAgain();
}
}

Replace tryAgain(); with whatever you want it to do!

FlyingColours
FlyingColours
  • Member since: Jul. 3, 2011
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to Input fields 2011-07-16 11:25:40 Reply

Sorry, it turns out that I did make a mistake! Please change nextframe to nextFrame.