# Help me understand hitTest

**URL:** https://forum.kirupa.com/t/help-me-understand-hittest/195768
**Category:** Uncategorized
**Created:** [August 2, 2006, 11:34pm UTC](https://forum.kirupa.com/t/help-me-understand-hittest/195768 "2006-08-02T23:34:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mimieux](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@mimieux](https://forum.kirupa.com/u/mimieux)
#### Post date: [August 2, 2006, 11:34pm UTC](https://forum.kirupa.com/t/help-me-understand-hittest/195768/1 "2006-08-02T23:34:32Z")

</div>

i don’t understand.  
why does this work:  
onClipEvent (enterFrame) {  
moveX = this.\_x;

```
if (num == 1) {
	this._x = moveX-5;
}
if (num == 2) {
	this._x = moveX+5;

}
if (this, hitTest(_root.block)) {
	num = 1;
}
if (this, hitTest(_root.block2)) {
	num = 2;
}

```

}

and this only works when one side of the bar is hit (the top side actually)

onClipEvent (load) {  
gotoX = random(10)+1;  
gotoY = random(10)+1;  
zY = 1;  
zX = 1;  
}  
onClipEvent (enterFrame) {  
//move  
\_x += (zX_gotoX), \_y += (zY_gotoY);  
//boundaries  
if (this.\_x\>=390) {  
zX = -1;  
} else if (this.\_x\<=10) {  
zX = 1;  
}  
if (this.\_y\>=590) {  
zY = -1;  
} else if (this.\_y\<=10) {  
zY = 1;  
}  
//change dir because hit bock  
if (this, hitTest(\_root.block1)) {  
zX = -1;  
zY = -1;  
}

}

if i change it to this:  
if (this.hitTest(\_root.block1.\_x, \_root.block1.\_y, true)) {  
zX = -1;  
zY = -1;  
}

it doesn’t work at all…

( i’m clearly not really geting hitTest…)

moo

“It is a mistake to think you can solve any major problems just with potatoes…”

-Douglas Adams
