# Collision detection using classes

**URL:** <https://forum.kirupa.com/t/collision-detection-using-classes/206386>\
**Category:** flash\
**Created:** [November 7, 2006, 6:33pm UTC](https://forum.kirupa.com/t/collision-detection-using-classes/206386 "2006-11-07T18:33:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chuckylefrek](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@chuckylefrek](https://forum.kirupa.com/u/chuckylefrek)\
**Post date:** [November 7, 2006, 6:33pm UTC](https://forum.kirupa.com/t/collision-detection-using-classes/206386/1 "2006-11-07T18:33:20Z")

</div>

[SIZE=2]Just trying to do a collision detection between 2 instances  
There is a ball movie clip created with a class called Ball.as And a player movie clip created with a class called Player.as  
The player movie clip has a nested movie clip called “hit\_mc” which I want to use for the collsion detection.  
I am trying the following and getting no script errors but not working either

var ball:Ball;  
var player:Player;  
player = new Player(this.theScene);  
ball = new Ball(this.theScene, 0,0,500);

if (player.hitTest(ball)) {  
trace (“BALL CAUGHT!!!”);  
}

Ideally I want something like  
if (player.hit\_mc.hitTest(ball)) {  
trace (“BALL CAUGHT!!!”);  
}

The superclass of both classes extends MovieClip  
i.e  
class Graphic extends MovieClip{

Any ideas what I need to do to get this to work?  
[/SIZE]
