# Moving an object along a curve with AS

**URL:** https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845
**Category:** Uncategorized
**Created:** [June 28, 2004, 12:40pm UTC](https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845 "2004-06-28T12:40:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ShulChi](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@ShulChi](https://forum.kirupa.com/u/ShulChi)
#### Post date: [June 28, 2004, 12:40pm UTC](https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845/1 "2004-06-28T12:40:49Z")

</div>

hello guys, … i’m stuck and i need your help 👼

i want to create a menu similar to The Infinite Menu ([Link here](http://www.kirupa.com/developer/mx/infinite.htm)), but with the difference that the menu will not run along a straight line, but along a curve (elipse).

I allready created a tween along a path, but it looks ugly when movement is slow, cuz of the limited frames 🅰

any you guys have any ideas how to make this?

tnx, Shulchi

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 14, 2004, 1:15pm UTC](https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845/2 "2004-07-14T13:15:50Z")

</div>

sup guys … did my homework 😃

here’s the result: [YEY!!!](http://www.kvants-visart.si/test/swf/testProfil.swf)

this was done using Prototypes Path(motion guide) class ([http://proto.layer51.com/d.aspx?f=952](http://proto.layer51.com/d.aspx?f=952) )

now i need some more help please! 😃

how can i attach more objects to this curve so that they will be appearing one after another with some space in between them.

I was thinking of a listener that triggers a attachMovie function to attach a new movie clip to the beggining of the curve.

But i don’t know how to tell that in Actionscript … please help 👼

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 14, 2004, 1:26pm UTC](https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845/3 "2004-07-14T13:26:08Z")

</div>

just make your objects and use an offset for t for each consectutive object that traverses the path.

… actually, come to think of it, Im going to edit that proto to allow t to wrap instead of chopping it off at 0 and 1 (so if you use 1.5 as t it will work as .5 and not 1)… maybe I should make that a parameter as well.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 16, 2004, 10:27am UTC](https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845/4 "2004-07-16T10:27:05Z")

</div>

yey!!! worked nicely !!! :king:

thanks :sen: , your proto works miracles 😃

see the result on the same link

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 16, 2004, 10:52am UTC](https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845/5 "2004-07-16T10:52:52Z")

</div>

only thing puzzling me is how to stop the movement when the last “planet” 😃 comes on stage. i tried several options including math.min and math.max, making t false, … but couldn’t fix it. :puzzle: Should i assign a new variable or function?? help me … Here’s the main AS code in my flash movie so far:

```auto
stop();

myPath = new Path(543, -110);
myPath.curveTo(625, -62, 659, 0);
myPath.curveTo(678, 34, 679, 73);
myPath.curveTo(670, 200, 524, 271);
myPath.curveTo(416, 325, 296, 348);
myPath.curveTo(182, 370, 76, 367);
myPath.curveTo(35, 367, 0, 365);
myPath.curveTo(-88, 359, -168, 340);

t = 0;

function mcSpeed() {
	var vAngle:Number;
	vAngle = Math.round(Math.atan(_ymouse/_xmouse)*180/Math.PI)-45;
	if (_xmouse<=0) {
		vAngle = 0;
	}
	if (_ymouse<=0) {
		vAngle = 0;
	}
	updateAfterEvent();
}
var clipInterval:Number = setInterval(mcSpeed, 10);

this.onEnterFrame = function() {
	t += -(vAngle/45)
	myPath.traverse(this.mcOglas1, t*.04, false, false);
	myPath.traverse(this.mcOglas2, (t-5)*.04, false, false);
	myPath.traverse(this.mcOglas3, (t-10)*.04, false, false);
	myPath.traverse(this.mcOglas4, (t-15)*.04, false, false);
	myPath.traverse(this.mcOglas5, (t-20)*.04, false, false);
	myPath.traverse(this.mcOglas6, (t-25)*.04, false, false);
	myPath.traverse(this.mcOglas7, (t-30)*.04, false, false);
}

```

mcOglas1 thru 7 are the planets :D.  
I want to make it so that, when the last planet comes to position, lets say y = 100, the movement stops in clockwise motion. The same for when the first planet goes offstage to a position of y= -80 that the movement stops in counterclockwise motion.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 16, 2004, 1:41pm UTC](https://forum.kirupa.com/t/moving-an-object-along-a-curve-with-as/55845/6 "2004-07-16T13:41:07Z")

</div>

\*\*\*\* … i don’t know why it didn’t work before but now it works fiiiiiiiiiiine 😃

added some “if” statements

YEAH!!!
