Issue with Input Text Comparison
Hello folks,
I have tried searching for an answer for this issue, but I haven't had any luck finding something that actually matches the issue.
I have created three input text boxes with the instance names: input001, input002, and input003.
The three boxes are used for a simple text value comparison for a question exercise.
The input text boxes have been input restricted so that only the values A, B, C, or D can be entered (representing the four possible answers).
I created a button and event listener, and the following function.
function submitBtn001Click(evt:MouseEvent):void{
trace("input001 = "+input001.text+" input002 = "+input002.text+" input003 = "+input003.text);
if(input001.text == "A" && input002.text == "D" && input003.text == "C"){
input001.type = "dynamic";
input002.type = "dynamic";
input003.type = "dynamic";
correct.alpha = 1;
submit_btn.visible = false;
}else if((input001.text !== "A" | input002.text !== "D" | input003.text !== "C") && tryAgain == 1){
tryAgain++;
trace(tryAgain);
submit_btn.visible = false;
reset_btn.visible = true;
incorrect_first_try.alpha = 100;
}else if((input001.text !== "A" | input002.text !== "D" | input003.text !== "C") && tryAgain >= 2){
input001.type = "dynamic";
input002.type = "dynamic";
input003.type = "dynamic";
incorrect.alpha = 100;
submit_btn.visible = false;
}
}
When I compile the SWF, I get the following error:
| 1067: Implicit coercion of a value of type Boolean to an unrelated type Number. |
The error is traced to the else if statements. If I comment out the else if statements, the SWF compiles without error and the code runs properly when I enter the correct answers in the input boxes (A, D, C).
What I don't understand is why my string comparisons in the else if statements are generating an error, or why that error would have anything to do with Boolean or Number, since I am comparing the text string value of the input boxes (input001.text, for example) with a string.
Thank you in advance for your assistance.