Groups | Blog | Home
all groups > flash actionscript > september 2006 >

flash actionscript : Loading Variables from Text file


kglad
9/17/2006 3:01:42 PM
kglad
9/17/2006 3:54:22 PM
if you use a LoadVars() object with instance name yourLV and if your text file
contains variables/values like:

&answer1=this is the answer to the first question&
&answer2=this is the answer to the2ndquestion&
etc

you can use something like:




function checkAnswersF(questionNumber,tf){ // questionNumber is the question
number, tf is the input textfield that should contain the answer to the question
if(yourLV["answer"+questionNumber].indexOf(tf.text.toLowerCase())){
trace("answer is correct");
} else {
trace("incorrect");
}
}
Essam Maccar
9/17/2006 5:18:34 PM
I am workin in a quiz that i will load the questions from variables in a
text file and i have passed this mission.
The problem is that i have input txt fields in my movie that the user will
put answers and i want to compare these answers with variables in a txt file
too :) is that valid and how can i please anybody reply me sooooon

Thank you

kglad
9/17/2006 5:23:51 PM
Essam Maccar
9/17/2006 6:11:21 PM
How Please give me an example

[quoted text, click to view]

Essam Maccar
9/17/2006 7:19:40 PM
ok this my situation and try to help me simpler than this
i have 3 input test fields named
name_txt , emailTxt , phonetxt.

and i have a text file named "question.txt" at the same folder.
i have three dynamic textfields that load &ques1 , &ques2 and &ques3
and i want to do the following:
i want to compare between the answers the user input and the answers at the
txt file &answer1,&answer2 and &answer3.

For example:
_root.submit_btn.onRelease = function(){
if ( _root.nametxt.text = = My variable ????){
gotoAndPlay(2);
} else{
gotoAndPlay(3);
}
}

Please help me that way and thank you for your efforts in advance
[quoted text, click to view]

Essam Maccar
9/17/2006 8:39:13 PM
The Code is


_root.loadVariables("ques.txt");
and my input txts named as following
name_txt
email_txt
phone_txt

and the text file ques.txt read as following:

&firstQ=What is your name?
&secondQ=What is your email?
&thirdQ=What is your mobile number?
&answer1=Essam
&answer2= my email
&answer3=0124613121

and i want to make a condition to compare between text input in the
name_txt,email_txt and phone_txt and &answer1, &answer2 , &answer3 and
that if ok gotoAndStop(where the next ques is) ;
Thank you Kglad

[quoted text, click to view]

Essam Maccar
9/18/2006 5:24:33 PM
Can any body Help
[quoted text, click to view]

AddThis Social Bookmark Button