PDA

View Full Version : snap into position!! OH THE PAIN!!!



webby
October 23rd, 2005, 09:03 AM
Hi,

I know its probably easy to do but after 3-4 hours of reading different bits on the net, i still can't get this to work. I would like to get the first movie clip to snap to the target and then play another movie clip. It all works except the snap.

Help please!

Could you explain if possible what the different parts of the code do, as i am interested in learning not just having someone do it for me!

thanks

Webby

Code on the button within the dragable movie clip:

on (press) {
startDrag("_root.drag1");
}
on (release) {
stopDrag();
if (_root.drag1._droptarget == "/test1") {
_root.outline1.gotoAndStop("done");
}
}

onemhunki
October 28th, 2005, 11:49 AM
I've built something like what your describing here, I'll have to dig out my old flash files to double check it, are you saying that you on (release) you want the dragable clip drag1 to snap to droptarget?

You need to get the x and y pos of the target first ie:

snaptox = _root.droptarget_x
snaptoy = _root.droptarget_y

then onRelease set the x and y of your draggable clip to correspond to the x and y of your target.

This works fine for me,




drag.onMouseDown = function () {
startDrag(drag, true);
}
drag.onMouseUp = function () {
stopDrag();
snaptotargetx = _root.droptarget._x
snaptotargety = _root.droptarget._y
drag._x = snaptotargetx
drag._y = snaptotargety
}



Hope that's clear, let me know how you get on.

Cheers