6 Replies Latest reply on Oct 14, 2011 2:23 PM by saratogacoach

    Conditional Statement in AS2 won't work

    saratogacoach Level 1

      Hi,

       

      Not able to find a similar tutorial in AS3, I'm using a tutorial for the Pong game done in AS2 (http://www.bezzmedia.com/swfspot/tutorials/flash8/Create_Pong). I've gotten it working, but would like to add a second frame that is played (shows text: "You Won!" or "Computer Won!") when the player or computer's (AI) score reaches a specific number (like 10).

       

      So far, can't get a simple conditional "if" to work. Nothing happens.

       

      In the ball's (paddleblock's) onClipEvent(enterFrame), when it increments the player's or computer's score variable (leftscore++ or rightscore++), I've added

       

       

      if (leftscore == 10) {gotoAndPlay(2);}

      or

       

      if (rightscore == 10) {gotoAndPlay(2);}

       

      On frame 2, depending on whether leftscore or rightscore = 10, a text box would display ("You Won!" for leftscore or "Computer Won!" for right score). So far, when tested, the game plays on frame 1, and when  10 (or 2 for quicker testing), nothing happens. The game just continues to play.

       

      I must be doing something wrong. Any help would be appreciated.

       

      (If more info, script, etc. needed, please advise.)

       

      Regards,

       

      saratogacoach