Skip to main content
Participating Frequently
June 14, 2012
Answered

Simple Quiz using ActionScript 1 and 2

  • June 14, 2012
  • 1 reply
  • 1085 views

Having a few problems with a simple quiz game in Flash CS4. When the correct answer is typed into the insert text box the wrong message on the wrong frame comes up. I have tried using frame numbers in the actionscript and frame name flags. Whatever answer I type in it sends me to the wrong frame. I cannot see what the problem is. Could you take a look for me. I have added the code below. FOnts are embedded - have tried embed all etc. My button is called Ent and the input text box is A1. I have disabled keyboard short cuts in the flash player too. Tried running .SWF fiel on its own.

From teh code below when my flash file runs I type in NaCl but the frame containg a message Q1F (below) is called. I cannot see why it is not Q1T. I have tried using 3 adn 4 in brackets without quotes as well. I have also tried using _root.gotoAndStop()

Regards

teacheRuss

Ent.onRelease = function() {

    if(A1.text == "NaCl")
{

         _root.gotoAndPlay("Q1T")

      } else  { 
         _root.gotoAndPlay("Q1F")

      } 

This topic has been closed for replies.
Correct answer Ned Murphy

One thing to do is to investigate the textfield to make sure it is specified to be single line (not multiple).  You should also run a trace of A1.length to see if there are any characters you don't expect... should trace "4".  Also try putting traces inside each condition to see if it is always falling into the second condition regardless of your entry in the textfield.

1 reply

Ned Murphy
Legend
June 14, 2012

First try tracing the A1.text value before the conditional to see that it is what you expect it to be...

trace(A1.text);

if(A1.text == "NaCl")...

Participating Frequently
June 14, 2012

Ned

Thanks for the reply. The trace shows NaCl which should be the correct answer to this question.

teacheRuss

Ned Murphy
Ned MurphyCorrect answer
Legend
June 14, 2012

One thing to do is to investigate the textfield to make sure it is specified to be single line (not multiple).  You should also run a trace of A1.length to see if there are any characters you don't expect... should trace "4".  Also try putting traces inside each condition to see if it is always falling into the second condition regardless of your entry in the textfield.