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

Bubble

Get Adobe Flash player
by geko 26 Oct 2011
    Embed
/**
 * Copyright geko ( http://wonderfl.net/user/geko )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/f6hu
 */

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    
    public class FlashTest extends Sprite {
        private var bbl:Array = new Array();
        
        public function FlashTest() {
            graphics.beginFill(0x0);
            graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
            graphics.endFill();
            
            stage.addEventListener(MouseEvent.MOUSE_MOVE, bubble);
            addEventListener(Event.ENTER_FRAME, update);            
       }
       
       private function bubble(e:MouseEvent):void{
           bbl.push({x:stage.mouseX, y:stage.mouseY, r:Math.random()*5, c:0});
       }
       
       private function update(e:Event):void{
           // clear
           graphics.clear();
           
           // draw background
           graphics.beginFill(0x0);
           graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
           graphics.endFill();
           
           // draw bubbles
           for(var i:int = 0;i < bbl.length; i++){
               if (bbl[i].y < 0 || bbl[i].c > 47){
                   bbl.splice(i--,1);
                   continue;
               }

               graphics.beginFill(0x0000FF,0.6);
               graphics.drawCircle(bbl[i].x+Math.random()*bbl[i].r/2, bbl[i].y, bbl[i].r);
               graphics.endFill();
               bbl[i].y -= bbl[i].r/2;
               //b.c++;
           }
       }
    }
}