# Negative score in catching game?

**URL:** <https://forum.kirupa.com/t/negative-score-in-catching-game/326316>\
**Category:** Uncategorized\
**Created:** [December 6, 2011, 7:09pm UTC](https://forum.kirupa.com/t/negative-score-in-catching-game/326316 "2011-12-06T19:09:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiki19857](https://avatars.discourse-cdn.com/v4/letter/k/e495f1/32.png) [@kiki19857](https://forum.kirupa.com/u/kiki19857)\
**Post date:** [December 6, 2011, 7:09pm UTC](https://forum.kirupa.com/t/negative-score-in-catching-game/326316/1 "2011-12-06T19:09:35Z")

</div>

I’m trying to edit the actionscript of catching [[COLOR=darkgreen]game[/COLOR]](http://board.flashkit.com/board/showthread.php?p=4294071#) in which a object fall from top to bottom and if the catcher fail to catch the object and the object hit the bottom, the score is subtracted.

I got my code from [http://flashgameu.com/Catching\_Game\_…12-131621.html](http://flashgameu.com/Catching_Game_Part_2_id20090312-131621.html)

Here’s the code  
Code:

package {  
import com.greensock.\*;

```
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.Timer;
import flash.utils.getDefinitionByName;

public class CatchingSkittles extends MovieClip {
    var girlmouth:GirlMouth;
    var girlmouthfront:GirlMouthFront;
    var nextObject:Timer;
    var objects:Array = new Array();
    var score:int = 0;
    const speed:Number = 7.0;
    
    public function CatchingSkittles() {
        girlmouthfront = new GirlMouthFront();
        girlmouthfront.y = -49.00;
        girlmouth = new GirlMouth();
        girlmouth.y = 308.55;
        addChild(girlmouth);
        girlmouth.addChild(girlmouthfront);
        setNextObject();
        addEventListener(Event.ENTER_FRAME, moveObjects);
    }
    
    public function setNextObject() {
        nextObject = new Timer(1000+Math.random()*1000,1);
        nextObject.addEventListener(TimerEvent.TIMER_COMPLETE,newObject);
        nextObject.start();
    }
    
    public function newObject(e:Event) {
        var goodObjects:Array = ["Red","Purple","Yellow","Orange","Green"];
        
        if (Math.random() &lt; .5) {
            var r:int = Math.floor(Math.random()*goodObjects.length);
            var classRef:Class = getDefinitionByName(goodObjects[r]) as Class;
            var newObject:MovieClip = new classRef(); 
            newObject.typestr = "good";
        } else {
            r = Math.floor(Math.random()*goodObjects.length);
            classRef = getDefinitionByName(goodObjects[r]) as Class;
            newObject = new classRef(); 
            newObject.typestr = "good";
        }
        newObject.x = Math.random()*500;
        addChild(newObject);
        objects.push(newObject);
        setNextObject();
    }
    
    public function moveObjects(e:Event) {
        for(var i:int=objects.length-1;i&gt;=0;i--) {
            objects*.y += speed;
            if (objects*.y &gt; 425) {
                
                removeChild(objects*);
                objects.splice(i,1);
            }
            if (objects*.hitTestObject(girlmouthfront)) {
                if (objects*.typestr == "good") {
                    score += 5;
                } else {
                    score += 5;
                }
                if (score &lt; 0) score = 0;
                scoreDisplay.text = "Score: "+score;
                removeChild(objects*);
                objects.splice(i,1);
            }
        }  
        girlmouth.x = mouseX;
    }
}

```

}  
Help! It’s for my final project.

In addition, how do I end the game after the catcher fail to catch at least 5 objects to go to “game over” screen with final score displayed?
