ForumsProgramming ForumMaths Game

10 6955
BehemothBoy
offline
BehemothBoy
33 posts
Nomad

Hey guys,

I'm trying to make a maths game where two numbers are randomly generated and you have to add them together and type the answer into a input field. The thing is that it always says the answer is wrong.

Here is the code:

//Write random numbers in the text boxes
TextBox_txt.text = random(100);
TextBox1_txt.text = random(100);

//Sets the yes and no MC's visibility to false
Yes_mc._visible = false;
No_mc._visible = false;

//Check to see if the answer is right or wrong
Go_mc.onRelease = function() {
if (Answer_txt.text == TextBox_txt + TextBox1_txt) {
Yes_mc._visible = true;
}else{
No_mc._visible = true;
}
}

I would just like to know what it isn't working, thanks.

  • 10 Replies
Erasmus_Darwin
offline
Erasmus_Darwin
59 posts
Nomad

(Caveat: I don't do AS2, so I might be getting some things wrong.)

Answer_txt.text == TextBox_txt + TextBox1_txt

That's your problem. TextBox_txt and TextBox1_txt are objects. Obviously, you want TextBox_txt.text and TextBox1_txt.text.

However, you've still got another problem after that. "+" in a string context is concatenation, not addition. In other words, 5 + 2 gives you 7, but "5" + "2" gives you "52". So you need to convert them to numbers before trying to add them. I'm not sure of the syntax to do that in AS2 off-hand.

Brbrtwins
offline
Brbrtwins
62 posts
Nomad

Once u finish your math game i would like to play it xD

BehemothBoy
offline
BehemothBoy
33 posts
Nomad

hahahaha, it isn't vary fancy, but if you want to thats fine

BehemothBoy
offline
BehemothBoy
33 posts
Nomad

Hey, here is the link to the game.

http://itiz.in/q2i4

Zega
offline
Zega
6,921 posts
Peasant

It made me laugh! XD Haha, if you put it on here, it might reach the ranking 9.8/10!!!

Armorkage
offline
Armorkage
247 posts
Nomad

wow cool yes it is funny

BehemothBoy
offline
BehemothBoy
33 posts
Nomad

it might reach the ranking 9.8/10!!!


HAHAHAHHA oh yeah totally, lol.

it is funny


What's so funny?
forgottongaurdian
offline
forgottongaurdian
42 posts
Nomad

that kool... i have a friend at school that did the same thing but you drag numbers to the answers box... it was challenging but we did it... now its just a friggen assignment thing... lol

yz125
offline
yz125
256 posts
Peasant

f(x)={x² á¶á¶²á¶³ ¹âᵪ
{ 0 , if (áµ&ordf â  0
if (x) = 0

Answer : lim , f (x)= lim x² cos (1/x )=0
skip steps = F( 0 )

CALCULUS

yz125
offline
yz125
256 posts
Peasant

Opps looks like you cna't see the problem , lol sorry if this seems like spam , just go to my about to see the real problem

Showing 1-10 of 10