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

めたぼ

Get Adobe Flash player
by mononoahare 26 Dec 2008
// write as3 code here..
package{
    import flash.display.Sprite
    import flash.events.Event
    import flash.display.BitmapData
    import flash.display.Bitmap
    import flash.geom.Rectangle
    import flash.geom.Point
    import flash.filters.BevelFilter
    import flash.filters.GlowFilter
    [SWF(width="465", height="465", backgroundColor="0x0000FF", frameRate="30")]  
    public class Metaball extends Sprite
    {
        private var _tmpCanvas:Sprite
        private const _max:uint=4
        private var _ballAr:Array=[]
        private var _canvas:BitmapData
        private var _rect:Rectangle
        private var _pt:Point
        private var _newAlphaAr:Array=[]
        private var _bevelFilter:BevelFilter

        public function Metaball()
        {
            addEventListener(Event.ADDED_TO_STAGE,init);
        }
        private function init(e:Event):void
        {
            
            _bevelFilter=new BevelFilter (10, 45, 0x000066FF, 1, 0x000066FF, 1, 15, 15, 1, 2, "inner", false);
            setAlphaAr();
            _pt=new Point(0,0);
            _rect=new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
            _canvas=new BitmapData(stage.stageWidth,stage.stageHeight,true,0x000000);
           
             _tmpCanvas=new Sprite();
           addChild(_tmpCanvas);
            addChild(new Bitmap(_canvas));
            createBall();
        }

        private function setAlphaAr():void
        {
            for (var i:Number = 0; i<100; i++) {
	        _newAlphaAr.push(0x00000000);
            }
            for (var j:Number = 100; i<=255; i++) {
	        _newAlphaAr.push(0xFF000000);
            }
        }

        private function createBall():void
        {
            for(var i:uint=0;i<_max;i++){
                _ballAr[i]=new Ball(0,0,_tmpCanvas);
            }
            addEventListener(Event.ENTER_FRAME,render);
        }
        
        private function render(e:Event):void
        {
           
            for(var i:uint=0;i<_ballAr.length;i++){
                _ballAr[i].update();
            }
            _canvas.fillRect(_rect,0xffffff);
            
            _canvas.draw(_tmpCanvas);
            _canvas.paletteMap(_canvas,_rect,_pt,null,null,null,_newAlphaAr)
            //
            filters=[_bevelFilter];
         }
    }
   
}
    import flash.display.Sprite
    import flash.display.DisplayObjectContainer
    import flash.filters.GlowFilter
   
    class Ball {
        private var _x:Number
        private var _y:Number
        private var _particle:Sprite
        private var _main:DisplayObjectContainer
        private var speedX:Number=4
        private var speedY:Number=4
        private var dirX:int=1
        private var dirY:int=1
        private var _glowfilter:GlowFilter
        

        public function Ball(x:Number,y:Number,main:DisplayObjectContainer):void
        {
            _glowfilter=new GlowFilter(0x0022FF, 4.0, 32, 32, 1);
            
            _main=main;
            speedX=Math.random()*speedX;
            speedY=Math.random()*speedY;
            _x=465/2+x;
            _y=465/2+y;
            
            _particle=new Sprite();
            _particle.filters=[_glowfilter];
            setCircle();
        }

        private function setCircle():void
        {
            _particle.x=_x;
            _particle.y=_y;
            _particle.graphics.beginFill(0x0022FF,1);
            _particle.graphics.drawCircle(0,0,80);
            _particle.graphics.endFill();
            _main.addChild(_particle);
            
        }

        public function update():void
        {
            _x=_x+speedX*dirX;
            _y=_y+speedY*dirY;
            _particle.x=_x;
            _particle.y=_y;
            if(_x<60||_x>400){
                dirX= dirX*-1;
            }
            if(_y<60||_y>400){
                 dirY=dirY*-1;
            }
        }


    }