-
problems with eval when referencing variables in textfield
Hi,
I am creating a question and answer program in flash. I have a mc which contains a number of text boxes, half of which are dymanic text boxes for holding the questions, (instance names q1, q2, etc... and variable names ques1,ques2,etc...) and the other half are input text boxes (instance names a1, a2, etc... and variable names ans1,ans2,etc...) for holding the answers inputed by the user.
The answers are stored in an answers array. i am using the following code in a for loop inside the mc to check whether the answer entered into the text box is correct
if (this["ans"+i] == answer[i-1]){
stuff here including playing mc r1,r2, etc..
trace("correct")
}
else{
trace("wrong")
}
The code does not work, when i enter the correct number into the answer text box, "wrong " is always displayed. However when i use ans1 instead of this["ans"+i] it works. Does anyone know why this is and how to solve it?
Also using this["r"+i].gotoAndPlay(2) to play the movieclip r1,r2 etc... does not work so maybe i don't quite know how to use the eval function. Some one help please!!!
Thanks
John
-
hey, does anyone know the answer? THis thing is really bugging me!!!
Cheers John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|