# hitTest

**URL:** <https://forum.kirupa.com/t/hittest/5564>\
**Category:** Uncategorized\
**Created:** [September 16, 2002, 1:01am UTC](https://forum.kirupa.com/t/hittest/5564 "2002-09-16T01:01:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Burgess](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@Aaron\_Burgess](https://forum.kirupa.com/u/Aaron_Burgess)\
**Post date:** [September 16, 2002, 1:01am UTC](https://forum.kirupa.com/t/hittest/5564/1 "2002-09-16T01:01:12Z")

</div>

I was wondering if I’ve done something wrong, or it’s simply Flash (I use 5). I can’t get the hit test (true) to work on a clip that animates (all it does is grow in size). If I set the hittest to false so it just reads the box of the clip, and not the shape it works just fine. The clip in question is simply a circle.

---

<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:** [September 16, 2002, 6:49am UTC](https://forum.kirupa.com/t/hittest/5564/2 "2002-09-16T06:49:18Z")

</div>

Well… remember that a hit test based upon the actual dimensions of an object cannot be used to detect if two movie clips colide.

not sure if you’re trying to do that… but it’s the only rule of thumb I know on hittests.

The dimensional hittest is used, I believe, to detect if a movie clip is on a particular x and y location, rather than on another movie clip. This can be useful if you’re trying to see if the mouse has colided with the movie clip, but possibly little else.

---

<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:** [September 16, 2002, 7:18am UTC](https://forum.kirupa.com/t/hittest/5564/3 "2002-09-16T07:18:36Z")

</div>

If you’re using circles or simple shapes, you’re better off scripting your how hitTest method. Based on distance and stuff. D’you what i mean?

pom 🙂

---

<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:** [September 16, 2002, 9:32am UTC](https://forum.kirupa.com/t/hittest/5564/4 "2002-09-16T09:32:06Z")

</div>

Try this, pixel level hit test aren’t totally possible in flash, as quality settings of a movie, can put pixels out of line. You can do a simple hit test that tests the bounding boxes (the blue ones around your mcs) or an x y hit test. You can also do distance based hit tests.

Try this fla - I think it’s one of the most accurate ways of testing for a hit I’ve seen so far…

---

<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:** [September 16, 2002, 9:35am UTC](https://forum.kirupa.com/t/hittest/5564/5 "2002-09-16T09:35:42Z")

</div>

I use the hitTest frequently in my games and it is a pain to get an accurate hit test, but it can be done. There are always work arounds…

(plug) Some of the game flas on my site have good examples of hitTests in them(/plug)

Here’s a distance approximation based one:

---

<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:** [September 16, 2002, 9:48am UTC](https://forum.kirupa.com/t/hittest/5564/6 "2002-09-16T09:48:29Z")

</div>

I think the second one is better for a start. The first one looks very good though.

pom :asian:

---

<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:** [September 16, 2002, 4:58pm UTC](https://forum.kirupa.com/t/hittest/5564/7 "2002-09-16T16:58:15Z")

</div>

The second one is a simple da hit test, whereas the first one is as close to pixel based hit test as you’ll get. The second one is obviously useful for circle’s but the first can be used for irregular shapes.

---

<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:** [September 17, 2002, 12:30am UTC](https://forum.kirupa.com/t/hittest/5564/8 "2002-09-17T00:30:03Z")

</div>

i’ve always thought that hittest is true only when one shape passes over another…but does it actualy create “box” around the shape and anything in that area has a true hittest?

---

<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:** [September 17, 2002, 5:04am UTC](https://forum.kirupa.com/t/hittest/5564/9 "2002-09-17T05:04:51Z")

</div>

Yep. That’s why you can’t really use that method. There was a very good article somewhere about that, let me look for it.

pom :asian:

---

<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:** [September 17, 2002, 5:49am UTC](https://forum.kirupa.com/t/hittest/5564/10 "2002-09-17T05:49:50Z")

</div>

Well… you can use it Pom. :), it works quite well in any situation where the object is small, and uniform. In most gaming situations the regular hit test is very useful.

---

<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:** [September 18, 2002, 1:13am UTC](https://forum.kirupa.com/t/hittest/5564/11 "2002-09-18T01:13:42Z")

</div>

And where was my brain. Oh yeah, I forgot. Thanks for the Radius tip Flex. Back into it now…

---

<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:** [September 18, 2002, 8:15am UTC](https://forum.kirupa.com/t/hittest/5564/12 "2002-09-18T08:15:47Z")

</div>

radius is a pretty good idea actualy…though it would only work on a circle thats totaly uniform…I’ve used hit test for a couple of games…its not really that bad… it would be beter if it only picked it up when pne shape overlaps another… oh well 🙂
