I am really working to get this project completed (it’s an online cognitive psychology experiment), and I’m at the stage now of working out bugs and errors. So, I apologize in advance if I post a lot of questions.
Here’s some context on the project. A participant is shown a word and asked to indicate how many times they’ve seen that word throughout the course of the experiment. Responses are restricted to 0-4. If they respond:
[LIST]
[]2-4, they’re asked whether the background colors were the same or different each time they saw the word, and then they select the color of the various backgrounds
[]1, they select the color of the background
[]0, move on to next item
[]blank, require input before continuing
[/LIST]
I can get the program working correctly if a user responds 1, 2, 3, or 4. The problem is if the response is 0 or blank–the same code fails. If I allow the “0 condition”, below, to execute, it ALWAYS executes, regardless of the value of numberAnswer.
Lastly, I’m at a loss for how to make sure that the user actually enters a value before continuing. I tried if(numberAnswer*=="", but it would not execute that code correctly. I really appreciate any help you all can offer (as always).
Here’s what I have so far:
function executePresentationTest ():void{
//**Unrelated stuff here removed to make code shorter//
if(i==90)
{
gotoAndStop(8);
}
else
{
txtMainDisplay.text = "How many times was the below word presented (enter a number 0 - 4)?"
txtWordDisplay.text = testWord*
stage.focus = txtInput;
stage.addEventListener(KeyboardEvent.KEY_DOWN, record_responsepres)
}
}
function record_responsepres(evt:KeyboardEvent):void
{
if(evt.keyCode== Keyboard.ENTER)
{
txtInput.type=TextFieldType.DYNAMIC;
txtInput.border=false;
elapsedTime2=getTimer();
elapsedTime=elapsedTime2-elapsedTime;
elapsedTime=getTimer();
numberAnswer*=int(txtInput.text)
stage.removeEventListener(KeyboardEvent.KEY_DOWN,record_responsepres);
{
if(numberAnswer*=="4" || numberAnswer*=="2" || numberAnswer*=="3")
{
testQuestion();
}
else if (numberAnswer*=="1")
{
pickColors();
}
/*else if (numberAnswer*=="0");
{
trace("Executing if 0");
blackScreen2();
}*/
}
}
}