# hitTest (game developing)

**URL:** https://forum.kirupa.com/t/hittest-game-developing/251100
**Category:** flash
**Created:** [February 5, 2008, 12:41pm UTC](https://forum.kirupa.com/t/hittest-game-developing/251100 "2008-02-05T12:41:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sebba](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sebba](https://forum.kirupa.com/u/sebba)
#### Post date: [February 5, 2008, 12:41pm UTC](https://forum.kirupa.com/t/hittest-game-developing/251100/1 "2008-02-05T12:41:33Z")

</div>

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).

```auto

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);
			}
		}
	}
}

```
