A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: hmm, if statement question...

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    252
    Simple question. I have a button that set the variable for answer1 to 1 or 0 for a correct answer or incorrect answer. On the button proceed the following:


    on (release) {
    if (answer1=1) {
    field15 = field15 + 2;
    } else {
    field15 = field15 ;
    }
    gotoAndStop (35);
    }


    BUT, it adds 2 to the field15 variable no matter what...

    Any help would be great !

    Thanks,

  2. #2
    Pillow Daddy m_andrews808's Avatar
    Join Date
    May 2001
    Location
    London England
    Posts
    924
    This is a simple but very irritating problem if you do not spot what is wrong. The if statement should look like this:

    on (release) {
    if (answer1==1) {
    field15 = field15 + 2;
    }
    gotoAndStop (35);
    }

    Note the double equals used for the if condition, if you miss this out then strange things start to happen! Also the else part of your code is not needed- why tell the computer to make a variable what it already is?!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center