# \[Flash 8\] hitTest Help

**URL:** https://forum.kirupa.com/t/flash-8-hittest-help/221223
**Category:** flash
**Created:** [April 2, 2007, 5:17pm UTC](https://forum.kirupa.com/t/flash-8-hittest-help/221223 "2007-04-02T17:17:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tehchunk](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@tehchunk](https://forum.kirupa.com/u/tehchunk)
#### Post date: [April 2, 2007, 5:17pm UTC](https://forum.kirupa.com/t/flash-8-hittest-help/221223/1 "2007-04-02T17:17:11Z")

</div>

I am working on a project where I have several movie clips that the user can drag, but I’m trying to keep them confined in a circular area. I tried creating a movie clip that contains a shape of the surrounding area, and I figured I could set up a simple hitTest statement that detects when one of the mc’s is trying to leave the designated area. However, I cannot get it to work. Right now I’m just trying to have the computer print out some output when a hit is detected. Below is my code. Any ideas?

[SIZE=1]function dragStarter():Void {  
this.startDrag();  
this.onMouseMove = updateAfterEvent;  
}

function dragStopper():Void {  
this.stopDrag();  
delete this.onMouseMove;  
}  
[SIZE=2]  
// THIS IS THE FUNCTION THAT IS LOOKING FOR ANY HITS  
function checkBoundary():Void {  
if (this.hitTest(boundary\_mc.\_x, boundary\_mc.\_y, true)) {  
trace(“hit”);  
}  
}[/SIZE]

function attachDragScripts():Void {  
this.onPress = dragStarter;  
this.onRelease = dragStopper;  
this.onReleaseOutside = dragStopper;  
this.onEnterFrame = checkBoundary;  
}

for (var i = 1; i \<= 26; i++) {  
attachDragScripts.apply(\_root[“letter”+i+"\_mc"]);  
\_root[“letter”+i+"\_mc"].\_x = 100 + (Math.random() \* 400);  
\_root[“letter”+i+"\_mc"].\_y = 110 + (Math.random() \* 210);

```
if (i % 2 == 0) {
    _root["letter"+i+"_mc"]._rotation = (Math.random() * 15);
} else {
    _root["letter"+i+"_mc"]._rotation = (Math.random() * -15);
}

```

}[/SIZE]
