# Hit test difficulties

**URL:** <https://forum.kirupa.com/t/hit-test-difficulties/1733>\
**Category:** Uncategorized\
**Created:** [May 30, 2002, 2:07pm UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733 "2002-05-30T14:07:56Z")\
**Posts on this page:** 7\
**Page:** 1

<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 30, 2002, 2:07pm UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733/1 "2002-05-30T14:07:56Z")

</div>

Here is the scenario… I have a background image (a rectangle). I drag another smaller rectangle on top of it. The icon I dragged is duplicated and returns to the starting icon bank. At the place where I dropped the icon, a larger version of the icon appears via attachmovie. That works great. However, if I drag the icon on top of the new rectangle and let go, my icon is “lost” until I click… I am fairly certain that this is because there are two sprites on top of each other and flash is not sure what to do… What I WANT to happen is that I would do a hit test of some sort and tell flash to just return my icon to the bank. However, since it is confused, i cannot even get a hittest result. Any ideas on how to solve this?

---

<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 31, 2002, 12:44am UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733/2 "2002-05-31T00:44:59Z")

</div>

I don’t know if this will work for you but, may I suggest a different approach?\r\rI have done the following:\r\rbackground layer: a graphic of your icon (just a graphic).\r\rnext layer above: position your mc right on top of your graphic.\r\rnow, note the \_x and \_y of your mc. \r\rWith hittest, you can simply tell your mc to return to its original \_x and \_y. Try it! It saves from all the attachmovie and duplicatemovie, and has worked great for me.\r\rIf you still have trouble, let me know, and I’ll email and fla.\r\rGood luck!

---

<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 31, 2002, 12:11pm UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733/3 "2002-05-31T12:11:17Z")

</div>

Hmm not sure I understand. What I need is this: I have a door movie clip. I also have a door icon movie clip. if i drag the door icon movie clip to a blank area on my screen, it puts another door movie clip there just fine. however, if the door icon movie clip overlaps any of the door movieclips, when i \r\ron(release)\r\rthe action is lost. that is, instead of putting a door at that “this.\_x” location, it acts like i never release the mouse button and since things are meticulously balanced between on(release) and on(press) it screws things up… here’s what i got right now:\r\r\ron (press) \r{\r&nbsp &nbsp &nbsp &nbsp if (this.\_name == “rightHandDoorWithoutWindowIcon”)\r&nbsp &nbsp &nbsp &nbsp {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.doorDropTarget.\_visible = true;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp duplicateMovieClip(\_root.rightHandDoorWithoutWindowIcon, “rightHandDoorWithoutWindowIcon” + \_root.numDoors, \_root.numDoors);\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp startDrag(this);\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // Set the proper height and width of the door\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this.\_xscale = 540;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp this.\_yscale = 540;&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \r&nbsp &nbsp &nbsp &nbsp }\r}\r\ron (release) \r{\r&nbsp &nbsp &nbsp &nbsp if (this.\_name == “rightHandDoorWithoutWindowIcon”)\r&nbsp &nbsp &nbsp &nbsp {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp stopDrag();\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp doorX = this.\_x;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp doorY = 465;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.doorDropTarget.\_visible = false;\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // return the icon to the bank\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.rightHandDoorWithoutWindowIcon.\_x = \_root.xCord;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.rightHandDoorWithoutWindowIcon.\_y = \_root.yCord;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.rightHandDoorWithoutWindowIcon.\_xscale = 100;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.rightHandDoorWithoutWindowIcon.\_yscale = 100;\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // Adjust x and y coordinates to be within bounding box\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if (doorX \< 300)\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp doorX = 300;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp else if(doorX \> 540)\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp doorX = 540;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // Position the baseline of the door properly\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp eval("\_root.rightHandDoorWithoutWindowIcon" + \_root.numDoors).\_x = doorX;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp eval("\_root.rightHandDoorWithoutWindowIcon" + \_root.numDoors).\_y = doorY;\r\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // Set the proper height and width of the door\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp eval("\_root.rightHandDoorWithoutWindowIcon" + \_root.numDoors).\_xscale = 540;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp eval("\_root.rightHandDoorWithoutWindowIcon" + \_root.numDoors).\_yscale = 540;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.numDoors++;\r&nbsp &nbsp &nbsp &nbsp }\r&nbsp &nbsp &nbsp &nbsp else\r&nbsp &nbsp &nbsp &nbsp {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp \_root.numDoors–;\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp removeMovieClip(this);\r&nbsp &nbsp &nbsp &nbsp }\r}

---

<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 31, 2002, 12:58pm UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733/4 "2002-05-31T12:58:18Z")

</div>

HTML Comments are not allowed\r\r(apparantly the characters “-”, “-”, and “\>” are not allowed… i used them for an arrow sign. 🙂

---

<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 31, 2002, 1:35pm UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733/5 "2002-05-31T13:35:43Z")

</div>

Ah… I see what you mean. I’ll play with it some more. In the meantime, I’ll defer to the others…\r

---

<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 31, 2002, 2:34pm UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733/6 "2002-05-31T14:34:31Z")

</div>

K thanks. not sure why my link was not allowed to be posted, but in case i missed something, let me try it again. the app is located at:\r\r[www.collaborate.saic.com/oiusa](http://www.collaborate.saic.com/oiusa)\r\ryou go to “Design your own building”\rthen you go to steel \rthen 8x8\rthen left side\r\rthe bottom left hand door is the one i’m working on so if you need a visual, you should be able to get it from there.

---

<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:** [June 3, 2002, 7:12pm UTC](https://forum.kirupa.com/t/hit-test-difficulties/1733/7 "2002-06-03T19:12:14Z")

</div>

I have discovered the on (releaseOutside) command… for some reason, this fixed my hit test problem (well i dunno - wasn’t trying to do a hittest). now i can mouse up on an icon and the new one will appear as it should. so it’s all good. thanks 🙂
