# Hittest, collision detection?

**URL:** <https://forum.kirupa.com/t/hittest-collision-detection/169947>\
**Category:** Uncategorized\
**Created:** [November 21, 2005, 1:04pm UTC](https://forum.kirupa.com/t/hittest-collision-detection/169947 "2005-11-21T13:04:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ErikHK](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@ErikHK](https://forum.kirupa.com/u/ErikHK)\
**Post date:** [November 21, 2005, 1:04pm UTC](https://forum.kirupa.com/t/hittest-collision-detection/169947/1 "2005-11-21T13:04:49Z")

</div>

I don’t really understand this, when searching for it I’ve found several different ways, but all of them using some kind of hitTest. example:

```auto

if (this, hitTest(_root.object)) {
//my code
}

```

but this doesn’t work for my very beautiful game, here is the code:

```auto

onClipEvent(enterFrame) {
_x -= speedx;
_y += speedy;

if (this, hitTest(_root.stjarna)) {
this._x += 20;
}

if (Key.isDown(Key.UP)) {
//_rotation -= 2;
this._y -= 20;
	}
	
if (Key.isDown(Key.DOWN)) {
//_rotation += 2;
this._y += 20;
	}

if(_y>480){
_y = 480;	
}

if(_y<-20){
_y = -20;	
}

}

```

and here is the game: [http://erikhk.mine.nu/dump/files/rymdskeppv4.swf](http://erikhk.mine.nu/dump/files/rymdskeppv4.swf)  
the spaceship is named skepp, and the stars is named stjarna…  
what am I doing wrong?? I’ve tried at least 4 methods, none of them working (for me)…
