package com.funct { import flash.display.Sprite; public class Random5 extends Sprite { public function Random5() { super(); init(); } private function init():void { for (var i:int=0; i < 300; i++) { var b:Ball=new Ball(1); //var x1:Number=Math.random() * stage.stageWidth; var x1:Number=0; var x2:Number=Math.random() * stage.stageHeight; //循环的次数越多就靠近中间 for (var j:int=0; j < 6; j++) { x1+=Math.random() * stage.stageWidth; } //b.x=(x1 + x2) / 2; //注意,,,除以其倍数 b.x=x1 / 6; b.y=stage.stageWidth / 2 + Math.random() * 50 - 25; this.addChild(b); } } } }
转载于:https://www.cnblogs.com/ndljava/archive/2012/04/16/2452572.html