3 Replies Latest reply on Jul 27, 2016 7:02 AM by kglad

    Point system malfunction

    zayedi38332296

      A new issue with the game is that when I implemented minus points and the total score goes under 0, it shoots up to a big number, and I would like the total score to go negative, is there anyway to show this?

      Here's my code:

       

      var score:uint;

       

      function init():void

      {

          score = 0;

          scorecounter_txt.text = score.toString();

          Car1.buttonMode = true;

        Car1.points = 2;

          Car1.addEventListener(MouseEvent.CLICK, on_press);

          Car2.buttonMode = true;

        Car2.points = 2;

          Car2.addEventListener(MouseEvent.CLICK, on_press);

        Car3.buttonMode = true;

        Car3.points = 2;

          Car3.addEventListener(MouseEvent.CLICK, on_press);

        Car4.buttonMode = true;

        Car4.points = 2;

          Car4.addEventListener(MouseEvent.CLICK, on_press);

        Car5.buttonMode = true;

        Car5.points = 2;

          Car5.addEventListener(MouseEvent.CLICK, on_press);

        Car6.buttonMode = true;

        Car6.points = 2;

          Car6.addEventListener(MouseEvent.CLICK, on_press);

        Car7.buttonMode = true;

        Car7.points = 2;

          Car7.addEventListener(MouseEvent.CLICK, on_press);

        Car8.buttonMode = true;

        Car8.points = 2;

          Car8.addEventListener(MouseEvent.CLICK, on_press);

          Car9.buttonMode = true;

        Car9.points = 2;

          Car9.addEventListener(MouseEvent.CLICK, on_press);

        Car10.buttonMode = true;

        Car10.points = 2;

          Car10.addEventListener(MouseEvent.CLICK, on_press);

        Car11.buttonMode = true;

        Car11.points = 2;

          Car11.addEventListener(MouseEvent.CLICK, on_press);

        Car12.buttonMode = true;

        Car12.points = 2;

          Car12.addEventListener(MouseEvent.CLICK, on_press);

        Car13.buttonMode = true;

        Car13.points = 2;

          Car13.addEventListener(MouseEvent.CLICK, on_press);

        Car14.buttonMode = true;

        Car14.points = 2;

          Car14.addEventListener(MouseEvent.CLICK, on_press);

        Car15.buttonMode = true;

        Car15.points = 2;

          Car15.addEventListener(MouseEvent.CLICK, on_press);

        Truck1.buttonMode = true;

        Truck1.points = 4;

        Truck1.addEventListener(MouseEvent.CLICK, on_press);

        Truck2.buttonMode = true;

        Truck2.points = 4;

        Truck2.addEventListener(MouseEvent.CLICK, on_press);

        Truck3.buttonMode = true;

        Truck3.points = 4;

        Truck3.addEventListener(MouseEvent.CLICK, on_press);

        Truck4.buttonMode = true;

        Truck4.points = 4;

        Truck4.addEventListener(MouseEvent.CLICK, on_press);

        Motorcycle1.buttonMode = true;

        Motorcycle1.points = 6;

          Motorcycle1.addEventListener(MouseEvent.CLICK, on_press);

        Motorcycle2.buttonMode = true;

        Motorcycle2.points = 6;

          Motorcycle2.addEventListener(MouseEvent.CLICK, on_press);

        Motorcycle3.buttonMode = true;

        Motorcycle3.points = 6;

          Motorcycle3.addEventListener(MouseEvent.CLICK, on_press);

        Human1.buttonMode = true;

        Human1.points = -1;

          Human1.addEventListener(MouseEvent.CLICK, on_press);

        Human2.buttonMode = true;

        Human2.points = -1;

          Human2.addEventListener(MouseEvent.CLICK, on_press);

        Human3.buttonMode = true;

        Human3.points = -1;

          Human3.addEventListener(MouseEvent.CLICK, on_press);

        Human4.buttonMode = true;

        Human4.points = -1;

          Human4.addEventListener(MouseEvent.CLICK, on_press);

      }

       

       

      function on_press(event:MouseEvent):void

       

       

      {

       

       

          updateScore(MovieClip(event.currentTarget).points);

       

       

      }

       

       

      function updateScore(points:Number):void

       

       

      {

       

       

          score += points;

           scorecounter_txt.text = score.toString();

       

       

      }

       

       

       

       

      init();