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

forked from: Explosion(弾幕っぽくしたかった)

// forked from Susisu's Explosion(弾幕っぽくしたかった)
package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.PixelSnapping;
    import flash.filters.*;
    import flash.geom.Point;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import net.hires.debug.Stats;
    [SWF(width="512", height="512", backgroundColor="0x000000", frameRate="60")]
    public class Rain extends Sprite{
        private var stg:Sprite=new Sprite();
        private var bmpData:BitmapData=new BitmapData(512,512,true,0xff000000);
        private var stgBmp:Bitmap=new Bitmap(bmpData,PixelSnapping.AUTO,true);
        private var obj:Array;
        private var n:int=2000;
        private var timer:int=0;
        private var index:Array;
        private var onum:int=0;
        private var filterObj:BlurFilter;
        private var spd:Number;
        public function Rain(){
            obj=new Array(n)
            for(var i:uint=0;i<n;i++){
                obj[i]=new Array(4);
            }
            index=[0,0];
            addChild(stg);
            stg.addChild(stgBmp);
            
            stg.addEventListener("enterFrame", loop);
            filterObj=new BlurFilter();
            with(filterObj){
                blurX=2;
                blurY=2;
                quality=1;
            }
            spd=2;
            addChild(new Stats());
            //stg.addEventListener(MouseEvent.MOUSE_DOWN,function(e:Event):void{spd=0.25});
            //stg.addEventListener(MouseEvent.MOUSE_UP,function(e:Event):void{spd=2;});
        }
        private function loop(e:Event):void{
            bmpData.applyFilter(bmpData,bmpData.rect, new Point(0, 0),filterObj);
            spd=Math.sin(timer/45*Math.PI)*2+2;
            for(var i:uint=0;i<5;i++){
                onum=index[1]%n;
                var r:Number=Math.random()*2*Math.PI;
                obj[onum][0]=256;
                obj[onum][1]=256;
                obj[onum][2]=Math.cos(r)*0.5;
                obj[onum][3]=Math.sin(r)*0.5;
                index[1]++;
            }
            for(i=index[0];i<=index[1];i++){
                onum=i%n;
                obj[onum][0]+=obj[onum][2]*spd;
                obj[onum][1]+=obj[onum][3]*spd;
                if(Math.abs(obj[onum][0]-256)>256&&Math.abs(obj[onum][1]-256)>256)index[0]++;
                else bmpData.setPixel32(obj[onum][0],obj[onum][1],0xff00c0ff|((spd*0xff/4)<<16));
            }
            timer++;
            
        }
    }
}