how can i add score into this flash game?

I have made the start of a flash shooting game but i have no idea how to add score into it when i kill a bad guy... can anyone help??

ENEMY.AS:

package {

import flash.events.Event;
import flash.display.MovieClip;
import flash.display.Sprite;

public class enemy extends Sprite {
private var core:Object;
private var yd:Number;
private var xd:Number;
public function enemy() {
addEventListener(Event.ADDED_TO_STAGE,onadd);
}

private function onadd(e:Event) {
core=MovieClip(root);
yd = core.sp.y-y;
xd = core.sp.x-x;
addEventListener(Event.ENTER_FRAME,loop);

}

private function loop(e:Event) {

var angle:Number=Math.atan2(yd,xd);

x+=Math.cos(angle)*3;
y+=Math.sin(angle)*3;


for (var i:int = 0; i<core.bulletholder.numChildren; i++) {

var bulletTarget:Sprite=core.bulletholder.getChildAt(i);

var ris:Number=bulletTarget.y-y;
var run:Number=bulletTarget.x-x;
var dis:Number=Math.sqrt(Math.pow(ris,2)+Math.pow(run,2));

if (dis<100) {
if (run<0) {
x+=5.3;
} else {
x-=5.3;
}
}


if (hitTestObject(bulletTarget)) {
core.bulletholder.getChildAt(i).removeListeners();
core.bulletholder.removeChild(bulletTarget);

var boom:MovieClip = new explosion();
boom.x=x;
boom.y=y;
stage.addChild(boom);

removeEventListener(Event.ENTER_FRAME, loop);
core.removeChild(this);
}
}

}

public function removeListeners():void {
removeEventListener(Event.ENTER_FRAME, loop);
}
}
}

EXPLOSION.AS:

package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.media.Sound;
public class explosion extends MovieClip {
private var hit:Sound = new sfx_hit();
public function explosion() {
addEventListener(Event.ENTER_FRAME,xkill);
hit.play();
}

private function xkill(e:Event) {
if (currentFrame==framesLoaded) {

removeEventListener(Event.ENTER_FRAME,xkill);
parent.removeChild(this);
}
}
}
}

BULLET.AS:

package {
import flash.display.Sprite;
import flash.events.Event;

public class bullet extends Sprite {

private var sw:Number;
private var sh:Number;
private const _SPEED:int=15;
private const _OFFSTAGE:int=-10;

public function bullet():void {
addEventListener(Event.ADDED_TO_STAGE,onadd);
}

private function onadd(e:Event):void {
sw=stage.stageWidth;
sh=stage.stageHeight;
addEventListener(Event.ENTER_FRAME,loop);
}

private function loop(e:Event):void {
if (y<_OFFSTAGE) {
removeEventListener(Event.ENTER_FRAME,loop);
parent.removeChild(this);
}
y-=_SPEED;
}

public function removeListeners():void {
removeEventListener(Event.ENTER_FRAME,loop);

}
}
}


i know its long but i'm stuck on this...
 
Back
Top