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 Crockett
Select 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)
xDistance=Math.sin(angle * Math.PI/180)*mainDistance
yDistance=Math.cos(angle * Math.PI/180)*mainDistance
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.
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