0

I'm trying to make a quiz for my students. I'm going to use it through a projector and the students will raise their choice cards to answer the questions. So there's a button in each frame of question to show the correct answer after the students. So I need these buttons to get the correct answer from the answer key in the dynamic text fields for each answer in the last frame of the clip. I've tried to define instance names and call the instance name (q1, q2, q3, etc.) using button actions like this:

if (q1.text == "A"){
   AnswerA.play();
}
if (q1.text == "B"){
   AnswerB.play();
}
if (q1.text == "C"){
   AnswerC.play();
}
if (q1.text == "D"){
   AnswerD.play();
}

The correct answer is never shown. I also tried using variable names of the text fields in the same way but it didn't work, either. I couldn't manage to get values from the unvisited frame to the timeline span actions layer's first frame. What should I do to retrieve the data of the dynamic text fields to use them in ActionScript 2? Thanks in advance for any useful idea.

IceFlame
  • 3
  • 2

1 Answers1

0

Your problem is that you try access objects that doesn't exists at time of your call. Timeline frame structure in Flash working as initializer and destructor of objects which you created in visual interface. From program execution point of view, your TextField objects exists only in your last frame. So you should choice more efficient data structure. For example it could be Array. Place code in you first frame

answersArray = ["A","B","C","D"];

And check will be like this

if(answersArray[0]=="A"){
    AnswerA.play();
}

If you sure that you need dynamic textfields than they should stay at all you frames, but somewhere outside of screen or with _alpha set to 0;

If the problem is in accessing to text inside TF, than there is two properties which responsible for this - text and htmlText. If your htmlText checkbox in TF properties is checked, use htmlText instead of text.

Aspiro
  • 552
  • 3
  • 7
  • Thanks for your answer. I did something close to what you advised. I found out that the problem was caused by the fact that it can only load the variables after getting on to that frame, as you mentioned. So I defined variables in the first frame: `var q1:String = "A"; var q2:String = "B"; var q2:String = "C"; ...` and a `switch` controller for each answer button to check the answer. By the way, I needed an answer key in the end of the clip to see the answers, so I named the dynamic text fields of each question as q1, q2, q3, etc to get the value from the first frame. Thanks again. – IceFlame Dec 04 '13 at 14:37