b3ta.com board
You are not logged in. Login or Signup
Home » Messageboard » XXX » Message 2828321 (Thread)

# more
speedage
(, Wed 3 Mar 2004, 15:54, archived)
# That m3rlin b3ta locator thingy
doesnt do the little patch of water between the UK and France... :(
(, Wed 3 Mar 2004, 15:58, archived)
# less hastage =
more speedage




100% fact
(, Wed 3 Mar 2004, 15:58, archived)
# hey
got my drag/drop quiz working now - thanks

wonder if i could pick your brains a little more - do you know how to "tell" something to take more than one frame to get to it's target within actionscript? at the moment they jump immediatly to their targets/home and i would like them to glide gracefully ;)

i.e. tweening, but from within actionscript
(, Wed 3 Mar 2004, 15:59, archived)
# make it a movie clip with a stop frame at the start
then put the movement after that. give it an instance name and tell it to play
(, Wed 3 Mar 2004, 16:04, archived)
# the thing is
the MC is being dragged, so it could be dropped anywhere - i.e. i couldn't have the movement within the MC as it would change each time it was dropped (is this right?)
(, Wed 3 Mar 2004, 16:06, archived)
# what is it youre trying to move gracefully?
the drag MC after youve dragged it?
(, Wed 3 Mar 2004, 16:07, archived)
# yep -
the user will drag it to a target, and it will slide to the centre - if they drop it off-target it will slide back to it's start position.
(, Wed 3 Mar 2004, 16:09, archived)
# aha
if (correct = true) {
_root.draggable;
gotoandplay(2);
} else {
//it wont work for this it'll just snap back
}
(, Wed 3 Mar 2004, 16:11, archived)
# thought that might work
but not really
(, Wed 3 Mar 2004, 16:12, archived)
# would this work though?
i would think it would go to somewhere relative to the place it was dropped, rather than a pre-determined absolute location?
(, Wed 3 Mar 2004, 16:16, archived)
# yeah
not sure about that script
(, Wed 3 Mar 2004, 16:19, archived)
# there has to be a way
but i dont know off the top of my head.

www.flashkit.com

has some useful things you can download. search the galleries for something similar.
(, Wed 3 Mar 2004, 16:18, archived)
# err
its possible you could find some movement script and adapt it to your needs, such as making it move at a certain speed to a certain point
(, Wed 3 Mar 2004, 16:09, archived)
# i have been using this tutorial:
www.wildform.com/tutorials/draganddrop/?sid=P3OP-NLEP-3fc088299622d&ref=

which has the smooth-bit included - however it no longer works when i set it up for multiple targets (as we discussed last night)

I can't see where i'm going wrong so just wondered if you knew what the relevant section was..


this._x -= (this._x-this.myFinalX)/5;
this._y -= (this._y-this.myFinalY)/5;


i assumed it was the "/5" part, but if i include that, the drag just moves a small (1/5?) distance towards the target - without it it snaps in one frame
(, Wed 3 Mar 2004, 16:13, archived)
#
this._x -= (this._x-this.myFinalX)/5;

this._y -= (this._y-this.myFinalY)/5;

so it takes the current position takes off your final xy each time, try putting /5 in the () or spaces somewhere

or perhaps you need an onclipevent(enterframe) {
this._x -= (this._x-this.myFinalX)/5;

this._y -= (this._y-this.myFinalY)/5;
}

because then it will move slowly back, /5 should be the speed. You might need an if clause to stop it though so it doesn't use up cpu power when still doing that equation
(, Wed 3 Mar 2004, 16:22, archived)
# right..
i think i get it - i will have a bit more of a fiddle ;)

cheers again!
(, Wed 3 Mar 2004, 16:31, archived)
# no trouble
*doffs hat*
(, Wed 3 Mar 2004, 16:33, archived)
# if you use that
it will never actually get to its target (thoertically)
although I like your logic.
I also like flash mx
(, Wed 3 Mar 2004, 16:22, archived)
# 1/5 is right
you just need to keep doing it until you are close enough, so in the next frame put a gotoandplay back to this frame.

This causes it to loop forever, so in this frame, you need to check if it's as near as dammnit to where it should be, along the lines of

if abs(this._x-this.myFinalX)
(, Wed 3 Mar 2004, 16:37, archived)