[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Arc trajectory mc

Hello there,
I have a mc that I need to move from point A to point B, I don't want it to move straight but to describe an arc trajectory.
I know one of the options is to have an empty mc with the onClipEvent(enterframe) checking if the point A = point B, and then if not, do the math to get it there. If possible, I'd like to stick to that, I just need the appropiate equations.

Thanks in advance,

Cërf.
0
Cerf
Asked:
Cerf
  • 6
  • 2
2 Solutions
 
negatyveCommented:
this is a good script to start from.

onClipEvent(load){
      speed=5;
      radius=100;
      xcenter=200;
      ycenter=140;
      angle=0;
}
onClipEvent(enterFrame){
      _x = Math.cos(angle*Math.PI/180)*radius+xcenter;
      _y = Math.sin(angle*Math.PI/180)*radius+ycenter;
      angle += speed;
      if (angle > 359)angle -= 360;
}

are you using flash mx?
0
 
CerfAuthor Commented:
yes,
should I start trying that already?
0
 
CerfAuthor Commented:
hmm, watching the script, I can see that it uses a center to do the arc.
from what I need to do, that center will change, how can I recalculate it?

Hold on, let me put together a little graphic to illustrate it better...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CerfAuthor Commented:
Ok,
http://es.geocities.com/cerfx/flash/ and look for Q_21193604.swf it is just an image (3kb)
0
 
CerfAuthor Commented:
now, what I want to accomplish is the following,
..[numbers in the image]..
first state [1],
on rollOver option1 [2],
on rollOut option1, return to the previous state, but if from rollover1 I move the mouse to option2 then [3]

is it too confusing?
0
 
muso120999Commented:
I don't want any points for this comment, but...

> that center will change, how can I recalculate it?

I've had a look at your graphic, and, to me, it looks like the mini circle option is rotating around a constant origin that is the centre of the bigger circle!  In what way is the centre changing?  If the bigger circle is moving left/right with the options too, you could simply adjust negatyve's xcenter variable in the onEnterFrame event

muso
0
 
CerfAuthor Commented:
hi,
Thanks for the input muso!
Actually, if you didvide the distance between the points by 2 and project a perpendicular line from that center you can change the center accurately, however, the problem I'm having now is that I need to figure out how can I express that movement in terms of XY instead of an angle.

negatyve, are you still there?

Cërf.
0
 
muso120999Commented:
I have written a function previously here:
http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21162904.html

coord takes an angle and a radius, and returns to an object with x and y distance - you adapt this to use it to calculate your x and y movement...

Just a thought!

muso
0
 
CerfAuthor Commented:
Hey there, sorry I have been out for a while,
I didn't implement any of the solutions since I was in a hurry, although I'm sure that working those out I'd get what I needed.

Thank you.

Cërf.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now