# Hit test

**URL:** <https://forum.kirupa.com/t/hit-test/19895>\
**Category:** Uncategorized\
**Created:** [May 2, 2003, 3:55pm UTC](https://forum.kirupa.com/t/hit-test/19895 "2003-05-02T15:55:14Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![fishtank](https://avatars.discourse-cdn.com/v4/letter/f/b3f665/32.png) [@fishtank](https://forum.kirupa.com/u/fishtank)\
**Post date:** [May 2, 2003, 3:55pm UTC](https://forum.kirupa.com/t/hit-test/19895/1 "2003-05-02T15:55:14Z")

</div>

my hittest works only partially:

hittest is even true when the 2nd mc only touches the blue outline of the mc. does anyone know the answer?

(ive already searched the forums)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 2, 2003, 11:26pm UTC](https://forum.kirupa.com/t/hit-test/19895/2 "2003-05-02T23:26:49Z")

</div>

ummm could you be more specific??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 5:31am UTC](https://forum.kirupa.com/t/hit-test/19895/3 "2003-05-03T05:31:27Z")

</div>

imagine ive got 2 mc, both have got a non-rectangle in it. there is a blue border around it (like around any MC/button).

when i do a hittest, AS even sets it to true when the mc only hits the blue line (which is not visible when testing) and not the thing inside the movieclip.

ill post a picture later…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 5:50am UTC](https://forum.kirupa.com/t/hit-test/19895/4 "2003-05-03T05:50:02Z")

</div>

okay if i understand you correctly your using a square as a hit area what you need to do is make a solid square with no border place it on the top layer make sure it covers teh area you want to be the button and then in the color panel set its color to 0% alpha thatll do the trick and you will have a working button

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 6:09am UTC](https://forum.kirupa.com/t/hit-test/19895/5 "2003-05-03T06:09:56Z")

</div>

no thats not what i want.

ive got no time now, ill post a pic in the afternoon…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 9:12am UTC](https://forum.kirupa.com/t/hit-test/19895/6 "2003-05-03T09:12:37Z")

</div>

![](http://195.230.176.35/images/hittest.gif)

i want to do a hittest, which is true when the two circles hit ech other, and not the blue MC-outline…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 3:18pm UTC](https://forum.kirupa.com/t/hit-test/19895/7 "2003-05-03T15:18:30Z")

</div>

[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21582&highlight=hitTest](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21582&highlight=hitTest)

Thats what my search dug up.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 3:21pm UTC](https://forum.kirupa.com/t/hit-test/19895/8 "2003-05-03T15:21:03Z")

</div>

i found that too. but i do not need that with the pixel-x-y-coordinates. i need a hittest that tests the hit of the actual content of the movieclips. but thanks…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 5:50pm UTC](https://forum.kirupa.com/t/hit-test/19895/9 "2003-05-03T17:50:16Z")

</div>

i know what you need and that is the answer. YOu need to set the shape-flag to true. You put

hitTest(“mcthatyouwanttohitTest”, [SIZE=10] _ **TRUE** _ [/SIZE] )

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 3, 2003, 6:01pm UTC](https://forum.kirupa.com/t/hit-test/19895/10 "2003-05-03T18:01:26Z")

</div>

thanks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 4, 2003, 10:28am UTC](https://forum.kirupa.com/t/hit-test/19895/11 "2003-05-04T10:28:12Z")

</div>

doesnt work.

thats my code:

[AS]onClipEvent (enterFrame) {  
if (this, hitTest("\_root.block.shaddow",true)) {  
setProperty(\_root.block, \_y, \_root.trans.blocky);  
setProperty(\_root.block, \_x, \_root.trans.blockx);  
}  
}[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 4, 2003, 3:16pm UTC](https://forum.kirupa.com/t/hit-test/19895/12 "2003-05-04T15:16:11Z")

</div>

try:

this.hitTest(“MCyouWANTtoHIT”, TRUE)

that might work. I’m not sure, I haven’t used hitTest in forever so I’m a little rusty. If that doesn’t work someone else should be along with the answer 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 4, 2003, 3:30pm UTC](https://forum.kirupa.com/t/hit-test/19895/13 "2003-05-04T15:30:21Z")

</div>

i used your code, and the result is the following:

it doesnt work until i delete the “,true” (without qotations). but then the shape-flag does not work again… help would be much appreciated…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2003, 9:26am UTC](https://forum.kirupa.com/t/hit-test/19895/14 "2003-05-05T09:26:49Z")

</div>

how do u do the email and the shoutbox animation? I have been trying to do dat. When u click the email, it plays an animation then and when u click on the shoutbox, it close the previous animation and then open up the new one. How to give the action to the buttons? Pls advise

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2003, 9:54am UTC](https://forum.kirupa.com/t/hit-test/19895/15 "2003-05-05T09:54:17Z")

</div>

with variables and if-statements.

im in school right now and am not able to post the answer right now, but ill post it tomorrow…

next time please PM me, not answer on a post in which i ask for something…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2003, 3:04pm UTC](https://forum.kirupa.com/t/hit-test/19895/16 "2003-05-05T15:04:25Z")

</div>

I couldn’t get it to work correctly at all. Its been so long. Oh, well… I just wrote my own prototype for it instead. As long as you are using circles this will work. I attached the file… let me know if this helps

```auto
MovieClip.prototype.hit = function (mcClip)
{
	this.x1 = this._x;
	this.y1 = this._y;
	this.xDis = (mcClip._x - this.x1);
	this.yDis = (mcClip._y - this.y1);
	this.maxD = (this._width / 2) + (mcClip._width / 2);
	this.hyp = Math.sqrt ((this.xDis * this.xDis) + (this.yDis * this.yDis));
	if (this.hyp < this.maxD)
	{
		return true;
	}
	else
	{
		return false;
	}
};
mc1.startDrag (true);
_root.onEnterFrame = function ()
{
	mc1.hit (mc2);
};

```

now, all you have to do is put an if statment like:

```auto

if(mc.hit(mc2)){
// do this if true...
}else{
//do this if false...
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 5, 2003, 3:27pm UTC](https://forum.kirupa.com/t/hit-test/19895/17 "2003-05-05T15:27:59Z")

</div>

thanks i will try it soon

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 10, 2003, 5:44pm UTC](https://forum.kirupa.com/t/hit-test/19895/18 "2003-05-10T17:44:36Z")

</div>

Yes, just check if their radiuses and distances are close enough to each other.
