Log in

View Full Version : startDrag / stopDrag Question...



tomyknoker
05-17-2007, 06:02 AM
Hi all...

I have the following:


main_left.dragbar_mc.onPress = function ()
this._parent.startDrag(false);
};

main_left.dragbar_mc.onRelease = dragbar_mc.onReleaseOutside = function () {
this._parent.stopDrag();
};

Very simple, was wondering how when I drag it I can give it a bit of a tweening affect, so when you let go it still moves and slow down to a stop... Also I want to have a reset button, that when clicked brings the MC back to the original position the MC was in during the inital first play... Can this be done?

Medyman
05-18-2007, 03:22 AM
I'll answer your second question first...

Yes this can be done.

Is the position where you would like it to start exact? Meaning can you pinpoint the exact coordinates of where you would like it to begin? If so, it's quite simple...

Simply add the _x and/or _y properties to those coordinates within the reset function. Something like this:


btn_reset.onRelease = function() {
movieclip._x = startingpoint;
movieclip._y = startingpoint;
}

if the coordinates of your MC are fluid and/or dynamic, its much the same princple, you'll just need to use some logic to pinpoint where the MC needs to go.


As far as your second question, I wouldn't use the startDrag/stopDrag functions for that purpose. I would use a tween engine (MCTeen, Fuse, or even the Tween class if you're not familiar with those).

Basic logic:
on Mouse press the MC moves in accordance with the x and y coordiantes of the mouse. on release, the MC is tweened +/- a certain amount of pixels using the "back" or "bounce" tween.

Let me know if you have any questions.