package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class Main extends Sprite { public function Main():void { stage.addEventListener(Event.ENTER_FRAME, update); stage.addEventListener(MouseEvent.CLICK, onClick); } private function update(e:Event):void { for (var i:int = 0; i < 10; i++) { var b:Ball = new Ball(); b.x = Math.random() * stage.stageWidth; b.y = Math.random() * stage.stageHeight; addChild(b); } } private function onClick(e:MouseEvent):void { removeChildren(); } } } import flash.display.Shape; class Ball extends Shape { public function Ball() { this.graphics.beginFill(0xffffff * Math.random()); this.graphics.drawCircle(0, 0, 10); this.graphics.endFill(); } } FP11の新機能 removeChildren()