Hit test difficulties

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?

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!

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}

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

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

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\rwww.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.

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 :slight_smile: