-
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
-
M.D.
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.
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|