Display elements in a circle


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.