ForumsProgramming ForumMaths Game

11 3627
BehemothBoy
offline
BehemothBoy
33 posts
20

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.

  • 11 Replies
Erasmus_Darwin
offline
Erasmus_Darwin
62 posts
20

(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
63 posts
50

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

BehemothBoy
offline
BehemothBoy
33 posts
20

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

BehemothBoy
offline
BehemothBoy
33 posts
20

Hey, here is the link to the game.

http://itiz.in/q2i4

Zega
offline
Zega
6,969 posts
0

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

Armorkage
offline
Armorkage
249 posts
0

wow cool yes it is funny

BehemothBoy
offline
BehemothBoy
33 posts
20

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
20

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
260 posts
750

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

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

CALCULUS

yz125
offline
yz125
260 posts
750

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

s9b1
offline
s9b1
310 posts
1,365

I like math. So I like math game too. But I haven't seen any good/popular math game yet.

Showing 1-11 of 11