Forums

ForumsProgramming Forum

Maths Game

Posted Jan 30, '09 at 3:23am

BehemothBoy

BehemothBoy

35 posts

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.

 

Posted Jan 30, '09 at 9:41pm

Erasmus_Darwin

Erasmus_Darwin

62 posts

(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.

 

Posted Jan 31, '09 at 11:23am

Brbrtwins

Brbrtwins

66 posts

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

 

Posted Feb 1, '09 at 3:15am

BehemothBoy

BehemothBoy

35 posts

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

 

Posted Feb 1, '09 at 5:21am

BehemothBoy

BehemothBoy

35 posts

Hey, here is the link to the game.

http://itiz.in/q2i4

 

Posted Feb 1, '09 at 5:26am

Zega

Zega

6,544 posts

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

 

Posted Feb 1, '09 at 11:20am

Armorkage

Armorkage

165 posts

wow cool yes it is funny

 

Posted Feb 1, '09 at 4:49pm

BehemothBoy

BehemothBoy

35 posts

it might reach the ranking 9.8/10!!!

HAHAHAHHA oh yeah totally, lol.

it is funny

What's so funny?

 

Posted Feb 6, '09 at 1:55am

forgottongaurdian

forgottongaurdian

42 posts

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 :D

 

Posted Mar 17, '12 at 6:56am

yz125

yz125

196 posts

f(x)={x² ᶜᶲᶳ ¹⁄ᵪ
        {     0 ,       if (ᵪ) ≠ 0
             if (x) = 0     

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

CALCULUS

 
Reply to Maths Game

You must be logged in to post a reply!