Posted By

kajyr on 02/02/10


Tagged

space round stage actionscript3 DisplayObject


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

Demian
adrianparr
TrentSkunk
davidino1978
alptugan


Display elements in a circle


 / Published in: ActionScript 3
 

URL: http://www.nightdrops.com/2009/quickreference-display-elements-in-a-circle

  1. public static function circle(items:Array, center:Point, distance:Number = -1, initialAngle:Number = 0):void {
  2. var step:Number = (2* Math.PI) / items.length;
  3. var angle:Number = initialAngle;
  4. for each (var d:DisplayObject in items) {
  5. if (distance < 0) distance = d.height+10 / Math.sin(step);
  6. d.x = center.x + distance * Math.cos(angle);
  7. d.y = center.y + distance * Math.sin(angle);
  8. angle += step;
  9. }
  10. }

Report this snippet  

You need to login to post a comment.