hitTest (game developing)

Me and a friend are making a game in actionscript 3. It’s a typical horizontally-scrolling spaceshooter, only with a viking theme.

We are having some trouble getting the enemies to disappear when they are hit by the dragon’s fireballs (yes, we have a dragon AND fireballs). The event that occurs when the collision happens resides in the enemy-class file.

What is the best way to resolve our problem?

Here is the code for the collision-detection in the enemy-class:

(Keep in mind that we are completely new to actionscript and that this is our first as project).


package {

	import flash.display.*;
	import flash.events.*;
	import flash.utils.*;

	public class Fiende1 extends BalderSpill {

		public function Fiende1() {
			this.scaleX=.7;
			this.scaleY=.7;
			this.addEventListener(Event.ENTER_FRAME, beveg);
			this.addEventListener(Event.ENTER_FRAME, checkCollision);
		}
		private function beveg(event:Event) {
			this.x-= 15;
		}
		public function checkCollision(event:Event) {
			if (drage_mc.hitTestObject(this)) {
				this.removeChild(this);
			}
		}
	}
}