PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
inputbox problem
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: inputbox problem

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    10

    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)
    }
    }
    }

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Be sure that your input text does not include a newline from pressing return.

  3. #3
    Member
    Join Date
    Dec 2009
    Posts
    84
    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)
            }
        }
    }

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    it wouldn't work for me, sad...

    Quote Originally Posted by dukeufan4 View Post
    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)
            }
        }
    }

  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center