Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : How-to Snap MC released on another?



Flicka
2/20/2004 6:18:20 PM
I'm an AS novice- but upon releasing a MC dragged upon another, I'd like it to
snap into a final position over the drop MC. Since I don't want it to be fixed
global coordinates, I think I should be able to get the drop MC global
coordinate (via its registration point at local coordiantes 0,0 ??) and move
the drag MC accordingly. I can't seem to work out the different coordinates
between the MCs, etc. I'd appreciate any help and would welcome plenty of
step-by-step comments about such intracacies.
ShadowKnyte
2/23/2004 12:38:01 AM
If you wish to drag movieclip 1 (mc1) onto movieclip 2 (mc2) and have mc1 snap
to the position of mc2 then follow these steps:

1) When user clicks mc1 startDrag()
2) When user releases mc1 stopDrag() and do a hit test to check if it has been
dropped on mc2
3) If the mc1 has been dropped on mc2 the best method of 'snapping' is to set
mc1's x and y coordinates to those of mc2, and thus you have your snap effect.
If there has been no hit detection of mc1 and mc2 you might want to reset mc1
to its original position for example.
AddThis Social Bookmark Button