PDA

Click to See Complete Forum and Search --> : Have an object move to a clicked location



JaronSenna
10-23-2002, 11:35 AM
Hi All,

I guess my question belongs on this board:

I am doing my first Flash project, (the *real* Flash dude here is gone for a few weeks), and I'm a newbie.
I have mastered the basic stuff of movieclips and times, symbols and stuff, but now I need some math I think...

I have a scenery on the movie of some land and a night sky. When clicked in the night sky, some "fireworks" need to fly to that point and explode there. I have found something to learn how to write the explosion stuff, but how do I do it so that I click in the sky and the skyrocket flighs (preferrably in a slightly curved motion) to the point where the mouse was clicked...

Can anyone help me with that?

Best,
-- Jaron

xDrunkCowx
10-24-2002, 01:59 AM
Im not sure if this is what u want.. im kinda confused. but here:

onClipEvent (enterFrame) {
x = (getProperty(_root.drag,_x) - _x)/10;
y = (getProperty(_root.drag,_y) - _y)/10;
_x = _x += x;
_y = _y += y;
}

put that on the mc of the firework. Then make a mc called drag and put this on it:

onClipEvent (load) {
startDrag (this, true);
}

hope this helps

JaronSenna
10-24-2002, 08:58 AM
Thanks xDrunkCowx,
I have put that into action, and it works fine!

Maybe you can help me with my last two thingies as well:

In the end this will be a skyrocket/firework, shooting santa out of the sky :-) How can I make it so that the arrow of rocket is always turned towards santa, so it needs to rotate a bit I think?

Also, now the object is flying towards "santa" into a straight line.. is it possible to have it go there in a curved motion?

Hope someone can help...

Also, this line from DrunkCow's message:


x = (getProperty(_root.drag,_x) - _x)/10;


I see what it does, because it works, but exactly what happens there?

the getProperty gets the current position of the drag object on the x axis, and reduces that number with the current position of the rocket on the x axis.. that means that x is now holding the distance to travel over the x axis towards its "target". But the '/10' bit I don't get. I see that if I lower the number, then it gets there quicker, but to me it seems as if this way, the rocket never actually gets to the target... what am I missing here???

Thanks!
-- Jaron

xDrunkCowx
10-24-2002, 11:59 AM
First i forgot something change the code to this and del the other movie clip i made u make:

onClipEvent (enterFrame) {
x = (_root._xmouse -_x)/10;
y = (_root._ymouse -_y)/10;
_x = _x += x;
_y = _y += y;
}

Well whats hapening is:
The current _x of the mouse is subtracted from the _x of the rocket so we can get the distance then the distance is / by 10 so that way if the distance is 40 and you devide it by 10 then the speed is 4 so the rocket shoots really fast at first then as it looses speed (as it gets closer or has a smaller distance to the busting open place) and finally stops at the point and at the point it would then using ur code explode..