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

bubbles

[SWF(width="400", height="400")]
Get Adobe Flash player
by dgoodwin 06 Feb 2012
    Embed
/**
 * Copyright dgoodwin ( http://wonderfl.net/user/dgoodwin )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7418
 */

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    
    //[SWF(width="400", height="400")]
    
    public class Main extends Sprite    
    {
        private const bg:uint = 0xFFFF0088;
        
        private var buffer:BitmapData;
        private var canvas:Shape;
        
        public function Main()
        {
            canvas = new Shape();
            buffer = new BitmapData(stage.stageWidth, stage.stageHeight, false, bg);
            addChild(new Bitmap(buffer));
            stage.addEventListener(Event.ENTER_FRAME, draw);
            stage.addEventListener(MouseEvent.CLICK, reset);
        }
        
        private function draw(e:Event):void {
            canvas.graphics.clear();
            canvas.graphics.lineStyle(1, 0);
            canvas.graphics.beginFill(0xFFFFFF);
            canvas.graphics.drawCircle(random(-100, 500), random(-100, 500), random(5, 50));
            buffer.draw(canvas);
        }
        
        private function reset(e:Event):void {
            buffer.fillRect(new Rectangle(0, 0, stage.stageWidth, stage.stageHeight), bg);
        }
        
        private function random(from:Number, to:Number):Number {
            return from + Math.random() * (to - from);
        }
    }
}