dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Random Calculations

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Posts
    20

    Random Calculations

    Hi everyone i've been trying to get a calculation working where i get a randomly generated number and have the user mentally divide it by 10 then enter an answer. I keep getting the answer as incorrect and i dont know why
    I have 3 text boxes
    dy1 - dynamic for the random number
    dy2 - input for the answer
    dy3 - dynamic for "Correct" or "Incorrect"
    And 2 buttons
    randomnum - to get the random number
    calculatenum - for the user to get the result of their answer

    the code i have so far is...

    var calc = (ranNum)/10;
    randomnum.onRelease = function() {
    var ranNum = Math.round(Math.random()*100)/100;
    _root.dy1 = ranNum;
    }

    calculatenum.onRelease = function() {
    var input = Number(_root.dy2);

    if(input = calc){
    _root.dy3 = "Correct";
    } else {
    _root.dy3 = "Incorrect";
    }
    }

    Im no the greatest at programming so please forgive any newbie mistakes

  2. #2
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    maybe try getting the text from the actual textField

    var input = Number(myInputBox.text);

    also, trace out some variables, in the calcnum function:

    calculatenum.onRelease = function() {

    trace(input+" "+calc)
    }

    if anything is undefined then tell us what.
    lather yourself up with soap - soap arcade

  3. #3
    Junior Member
    Join Date
    Oct 2007
    Posts
    20
    thanks i've managed to solve the problem now

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