In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

FP11の新機能 removeChildren()

wonderflがFP11に対応したと聞いて、FP11の新機能removeChildren()メソッドのテスト

クリックするとremoveChildren()が呼ばれます
Get Adobe Flash player
by ton 20 Oct 2011
/**
 * 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();
    }
}