- Home
- Tutorials
- Flash
- Intermediate
- Orbiting in AS2
Orbiting in AS2

ActionScript
Andy Crockett
Loved writing code since I started a couple months ago, and I get pissed to see the lack of useful tutorials for widely used subjects on the web.
View all articles by Andy CrockettSelect ActionScript 2.0:
Create two MovieClips, Give the one which you wish to orbit around an instance name of "center" (no quotations)
the other you can name whatever you like. Lets say you named it bob.
Click on bob
open the actions panel (f9)
insert the following: (or type it out maually to help you remember)
onClipEvent(load){
angle=0//degrees
mainDistance=100//pixels
}
onClipEvent(enterFrame){
angle+=5
xDistance=Math.sin(angle * Math.PI/180)*mainDistance
yDistance=Math.cos(angle * Math.PI/180)*mainDistance
xDisCalculated=_root.center._x-xDistance
yDisCalculated=_root.center._y-yDistance
this._x=xDisCalculated
this._y=yDisCalculated
}
and if your looking for this in as3 its really not that hard to convert even if your a beginner,
but im too lazy to do it so sorry.
explained:
the onLoad is setting the variables "angle" and "mainDistance"
in the next block:
it adds 5 to the "angle" variable every frame
the "xDistance" is calculated using the sine of "angle" / radian( or Math.PI/180) times the "mainDistance" (how far away it is from the mc
the "yDistance" is calculated using the cosine of "angle" / radian( or Math.PI/180) times the "mainDistance" (how far away it is from the mc
then xDisCalculated is just the _x position of your object (in this case NAME) minus the xDistance
then yDisCalculated is just the _y position of your object (in this case NAME) minus the yDistance
next the object which your coding _x position is told to equal xDisCalculated
next the object which your coding _y position is told to equal yDisCalculated
Spread The Word
Attachments
8 Responses to "Orbiting in AS2" 
|
said this on 12 Feb 2009 1:22:03 PM CST
Really cool science here.
http://ho |
|
said this on 17 Feb 2009 12:55:37 PM CST
Nice explanation of the m
it would be easie onClipEvent(load){ } onClipEvent(enterFr angle+=5; yDistance=Math. xDisCa yDisCalcu this._x=xDis this._y= } |
|
said this on 02 Mar 2009 4:10:55 AM CST
hi, first off, very good
I made something simil But now I want Can my email is grtz |
|
said this on 23 Mar 2009 7:35:02 PM CST
Pieter, all you would nee
yPo xPos=this._x-_root.cen angle2=Math.atan this._rotation=angle if bob isn't facing That shoul |
|
said this on 12 Jun 2009 8:51:11 AM CST
I tried this, first typin
|
|
said this on 12 Jun 2009 8:57:13 AM CST
Cancel that last comment.
|
|
said this on 15 Jul 2009 8:16:29 AM CST
now nest this 5 levels de
|
|
said this on 08 Sep 2009 11:48:05 PM CST
This is great!
And I als But I require to dra An As far as I knew,I d Please Thanks a lot.. |


Author/Admin)