Code:
target_mc.onPress = startDrag;
target_mc.onRelease = function () {
this.stopDrag();
if (this.hitTest(Goal_mc)) {
this._x = 50;
this._y = 50;
this.enabled = false;
this.filters = [gf];
}
}
import flash.filters.GlowFilter;
var gf:GlowFilter = new GlowFilter(0x339900, 100, 3, 3, 5, 3, false, false);
Target_mc is simply the MC you want to drag around.
onPress = what happens when the mouse is PRESSED.
onRelease is what happens when the mouse is RELEASED.
Be careful of upper lower case.
this.stopDrag means "this MC that we are in" which is the target_mc.
IF the hitTest (overlap, touching) is true between this (target_mc) and another mc (here the Goal_mc), then do what is in the {}.
move the MC's X coordinate to 50
move the MC's Y coordinate to 50 (or wherever you want it to snap to)
this.enabled = false means they can't drag it anymore.
this.filters, along with the two lines at the bottom (which should be at the top) simply make it glow a bit once it has touched its target and then jumped into place. It's not needed, but it does make it clear it has been locked into place correctly.