Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button Actionscript for dynamic text

Status
Not open for further replies.

Hihoshi

Technical User
May 22, 2007
3
I'm writing a quiz game based on dynamic text using .txt files for my variables so that the questions and answers can easily be changed later on down the road.

My problem is that the button actionscript won't seem to use the .txt files.

This is my code:

on (release, keyPress "<Enter>") {
if (answer eq "page1answer1.txt") {
gotoAndPlay ("Scene 4", 1);
} else if (answer eq "page1answer2.txt") {
gotoAndPlay ("Scene 5", 1);
} else if (answer eq "page1answer3.txt") {
gotoAndPlay ("Scene 6", 1);
} else if (answer eq "page1answer4.txt") {
gotoAndPlay ("Scene 7", 1);
} else if (answer eq "page1answer5.txt") {
gotoAndPlay ("Scene 8", 1);
} else {
gotoAndStop ("Scene 3", 1);
}
}


Is something like this at all possible? Can I use the .txt files and still be able to have a text based answer?

Thank you for your consideration.
 
Thanks for the info :D

I wasn't sure if I would have to load the vars first. Do I call to the vars instead of the .txt then?

Im using 8...but I used to flash a long time ago and I'm going on what I remember. -_-

Anyway thanks again for the post!
 
> Im using 8...but I used to flash a long time ago and I'm going on what I remember. -_-

Yes I can see that!

You may as well use the current script style. Have a look at "LoadVars" class in the doc. If you need help writing the code let me know.

Kenneth Kawamoto
 
I've been looking at LoadVars for a couple days now, but I just don't seem to be getting it. I've figured out how to load with it, and what the variables mean, but I just can't figure out how to use it for what I need it for.

I hate to ask for further help, normally I can find something if pointed in the right direction. But this time I'm thoroughly stumped.

I'll explain things in full detail.

I'm making a training game based on family feud for a classroom environment.
I have my basic layout looking something like this:

Question
Answer 1 hidden
Answer 2 hidden
Answer 3 hidden
Answer 4 hidden
Answer 5 hidden

Answer text box (user text input) <<Enter Button>>

If the user inputs the correct answer in the text box, it jumps to the unveiling of the corresponding answer.

The problem I keep running into is that I want all of the question and answer fields to be dynamic - so that any teacher can change them depending on the need, and without having to rewrite the whole thing and send it to them.

However, I also want it so that when someone types a correct answer in the text field, it recognizes that and sends it to the correct frame or scene.

I've looked at the LoadVars - and I see a few promising things, but I'm not sure if anything can do what I'm looking for.

I'm sorry to ask for further help, but this has really got me stumped.

Thanks in advance, I appreciate it.
 
I would use XML - you can just put all of your data in one file.

Something like...

<question id="1">
<text>Question 1 text</text>
<answer id="1">Answer 1 text</answer>
<answer id="2">Answer 2 text</answer>
<answer id="3">Answer 3 text</answer>
<answer id="4">Answer 4 text</answer>
<answer id="5">Answer 5 text</answer>
</question>
<question id="2">
...


Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top