package com.funct { import flash.display.Sprite; /** *随机布局 * @author Administrator * */ public class Random2 extends Sprite { public function Random2() { super(); init() } private function init():void { for (var i:int=0; i < 300; i++) { var b:Ball=new Ball(1); var radius:Number=Math.random() * 50; //注意这里 //var radius:Number=Math.sqrt(Math.random()) * 50; var angle:Number=Math.random() * (Math.PI * 2); b.x=stage.stageWidth / 2 + Math.cos(angle) * radius; b.y=stage.stageHeight / 2 + Math.sin(angle) * radius; this.addChild(b); } } } }
转载于:https://www.cnblogs.com/ndljava/archive/2012/04/16/2452157.html