FP11の新機能 removeChildren()
wonderflがFP11に対応したと聞いて、FP11の新機能removeChildren()メソッドのテスト
クリックするとremoveChildren()が呼ばれます
/**
* Copyright ton ( http://wonderfl.net/user/ton )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8ChQ
*/
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();
}
}