2 Replies Latest reply on Dec 12, 2007 8:59 AM by BSpero

    Variable/"Text" Boxes

      Wow, is this ever frustrating. Here's the story:

      I have a powerup in my Ping Pong game that adds one point to a players score, if they are the player to get it. The default score of the player (in stock mode, but as if that matters) is 10. If that remains unchanged (as you can change it in the game), All is happy-go-lucky, and if a person hits that power up, there score goes from 10 to 11. Yay.

      BUT, if you change the score default to anything else, whenever you hit the powerup, rather than going up by 1 point, it "concatenates" it. (Example: Default score has been set to 5, the powerup is supposed to ADD 1, but strings it together, and makes it 51, instead of 6). BAH

      if (_root.Ball.hitTest(this)) {
      if (_root.Possession == 1) {
      _root.PlayerOne.PlayerOneScore += 1;
      <-- This is where the problem is...
      _root.ScoreShowerP1 = true;

      Any help is appreciated. THANKS!

      --- Matt
        • 1. Re: Variable/&quot;Text&quot; Boxes
          kglad Adobe Community Professional & MVP
          the problem is PlayerOneScore is a string when it's not 10. are you using a textfield to change the default score?
          • 2. Variable/&quot;Text&quot; Boxes
            BSpero Level 1
            Somewhere along the line, you are setting the score to a string. Like kglad said, if you are pulling it from a textfield or other text box, that could be causing the problem. If one part of an expression is a string, Flash will automatically convert the whole thing, and that is where you are getting your issue. It's best to figure out where this is happening, and change it, but you could use add a line in there to make sure you have a number in your variable with: