Be a Supporter!

Math Equations

  • 234 Views
  • 3 Replies
New Topic Respond to this Topic
Gaaz
Gaaz
  • Member since: Feb. 28, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Math Equations 2013-01-17 10:16:07 Reply

I'm trying to develop a math app. When a user is pretended with a question such as 1+1 the user is required to type in the answer. If the user puts 2 they will go to the next frame, else the user stays on the same frame.

How do I go about doing this? I have tried

if ("textbox" = 2)
{
gotoAndStop(2)
}
;

"textbox" being the input text field and the value of what the user should type "2".


I HAD BIGBADRON'S LAST EVER LOCK
PM if you like or dislike my sig.
Liked (12) Disliked (3)

BBS Signature
4urentertainment
4urentertainment
  • Member since: Aug. 1, 2008
  • Offline.
Forum Stats
Moderator
Level 13
Game Developer
Response to Math Equations 2013-01-17 10:27:11 Reply

if ("textbox" = 2)

There are so many things wrong with this one line. Taking the time to learn the basics of the language is really important.

First of all, you're using "=". The equal operator is used to assign a value to a variable. What you want is to check the equality of something, so you do "==".

myVar = 2 //gives myVar a value of 2
myVar == 2 //checks if myVar is equal to 2, and returns true or false

Second, what you're doing here is checking a string against a number.

Third, the way you access the text inside a text box is by

textBox.text
Gaaz
Gaaz
  • Member since: Feb. 28, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to Math Equations 2013-01-17 10:36:17 Reply

At 1/17/13 10:27 AM, 4urentertainment wrote:
if ("textbox" = 2)
There are so many things wrong with this one line. Taking the time to learn the basics of the language is really important.

First of all, you're using "=". The equal operator is used to assign a value to a variable. What you want is to check the equality of something, so you do "==".

myVar = 2 //gives myVar a value of 2
myVar == 2 //checks if myVar is equal to 2, and returns true or false

Second, what you're doing here is checking a string against a number.

Third, the way you access the text inside a text box is by

textBox.text

I've tried attaching it to the instance in a MC and on a frame but it still doesn't work.

{
//var answer;
if (answer.text == 1)
{
gotoAndStop(2);
}
}


I HAD BIGBADRON'S LAST EVER LOCK
PM if you like or dislike my sig.
Liked (12) Disliked (3)

BBS Signature
MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Math Equations 2013-01-17 17:15:47 Reply

Your big problem is using AS2, and using it on MovieClips no less. If it was AS3 you could just post all your code, but with AS2 someone would have to look though your fla and make sure your names, frame, and events around the code are set correctly. Do yourself a favour, if you ever plan on becoming a programmer switch to AS3.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature