-
inputbox problem
When the answer inputed from the text box matches with the answer in array then it will trace correct, but even after I entered the correct answer it will still tell me I'm wrong. Can someone help me with this please
var possible:Array=new Array()
var questionran:int
var plusran:int
var checker:int
questionran=Math.random()*12+1
if(questionran==1){
plusran=Math.random()*6+1
questionran=questionran+plusran
}
trace(questionran)
possible[12]=1
possible[11]=2
possible[10]=3
possible[9]=4
possible[8]=5
possible[7]=6
possible[6]=5
possible[5]=4
possible[4]=3
possible[3]=2
possible[2]=1
questionone.text="Suppose two dice are rolled and you want the sum of the two dice to be "+" "+String(questionran)+" "+
"How many ways can this occur?"
check1_btn.addEventListener(MouseEvent.CLICK,check ing)
function checking(e:MouseEvent){
switch(e.currentTarget){
case check1_btn :
checker=possible[questionran]
trace(checker)
if(input1.text==String(checker)){
trace("correct")
}
else{
trace("wrong")
trace(input1.text)
}
}
}
-
Be sure that your input text does not include a newline from pressing return.
-
Worked fine for me. Here is the exact code that I used:
Actionscript Code:
var possible:Array=new Array(); var questionran:int; var plusran:int; var checker:int; questionran=Math.random()*12+1; if(questionran==1){ plusran=Math.random()*6+1; questionran+=plusran; } trace(questionran); possible[12]=1; possible[11]=2; possible[10]=3; possible[9]=4; possible[8]=5; possible[7]=6; possible[6]=5; possible[5]=4; possible[4]=3; possible[3]=2; possible[2]=1;
questionone.text="Suppose two dice are rolled and you want the sum of the two dice to be "+" "+String(questionran)+" "+ "How many ways can this occur?" check1_btn.addEventListener(MouseEvent.CLICK,checking) function checking(e:MouseEvent){ switch(e.currentTarget){ case check1_btn : checker=possible[questionran] trace(checker) if(input1.text==String(checker)){ trace("correct") }else{ trace("wrong") trace(input1.text) } } }
-
it wouldn't work for me, sad...
Originally Posted by dukeufan4
Worked fine for me. Here is the exact code that I used:
Actionscript Code:
var possible:Array=new Array(); var questionran:int; var plusran:int; var checker:int; questionran=Math.random()*12+1; if(questionran==1){ plusran=Math.random()*6+1; questionran+=plusran; } trace(questionran); possible[12]=1; possible[11]=2; possible[10]=3; possible[9]=4; possible[8]=5; possible[7]=6; possible[6]=5; possible[5]=4; possible[4]=3; possible[3]=2; possible[2]=1;
questionone.text="Suppose two dice are rolled and you want the sum of the two dice to be "+" "+String(questionran)+" "+ "How many ways can this occur?" check1_btn.addEventListener(MouseEvent.CLICK,checking) function checking(e:MouseEvent){ switch(e.currentTarget){ case check1_btn : checker=possible[questionran] trace(checker) if(input1.text==String(checker)){ trace("correct") }else{ trace("wrong") trace(input1.text) } } }
-
solved it was multi line behavior
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
|