Reputation: 1
I'm wondering if there is a method to do a hit test object between two movieclips from the same class. The movieclips are being spawned into the stage using a for loop.
Is it possible to if(item(event.currentTarget).hitTestObeject(item(thats not being selected at the moment?)))
I'm doing a drag and drop game and am trying to not let the items stack above each other when dragged to the snapping slots on the stage. If not is there other methods avaliable? Thanks in advance (:
Upvotes: 0
Views: 1777
Reputation: 191
A few weeks ago I was working on a project wich had very specific dragging, so we've decided not to use the Flex DragManager. Our, so called, DragManager is not doing anything special. The thing that I think is related with your work is the presence of snap blocks. In our case the snap blocks were simple groups. Every snap block has a reference to the object wich was dropped into it(let's say it is droppedItem). When trying to drop an item, or even before triggering the snapping mechanism, there is a simple check in the snap block
if (droppedItem == null)
And this was the solution in our case. I'm not sure what are your snapping slots, but I hope that our approach will help you.
Best regards, Ivan
Upvotes: 0
Reputation: 2242
first of all, detecting, whether two display objects (sprites, movieclips, etc.) hit each other, is independent of the fact, that the objects are instances of the same class. The important thing is, you have two instances and they are display objects, so you're good to go.
If you want to do hit tests, then i would do the following:
Upvotes: 1