banner ad
Thursday, January 05, 2006
Circular movement

How do you make clips move along a circle using actionscript.  Should have something to do with angles, radiuses and sines cosines.  That is partially right, although there is more to it.  A small knowledge of mathematics is necessary.

Since at miniml all things stay simple, the code stays simple,  se we get and angle between 1 and 360 and calculate the value of the radian from that angle (why do we do this; silly cuz flash needs to see things in radians, would have been much easier to keep in degrees...); we assign xy values according to sin cosine of the radian.

	
// Radian Conversion
var radians= (_clip.angle/180) * Math.PI;
	
// Place the instance on the circle
_clip._x = centerX + Math.cos(radians) * radius;
_clip._y = centerY + Math.sin(radians) * radius;

here is an example


»comments
Name
URL
Email
*email address is not published
Remember Me
Comments

CAPTCHA






banner ad