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

CurveLaser(くるんくるんレーザー)

くるんくるんレーザー試作品
なんだか適当な処理だなと後になって思う。
Get Adobe Flash player
by Susisu 23 Apr 2010
//くるんくるんレーザー試作品
//なんだか適当な処理だなと後になって思う。
package{
	import flash.display.*;
	import flash.geom.Point;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import net.hires.debug.Stats;
	[SWF(width="512", height="512", backgroundColor="0x000000", frameRate="60")]
	public class Laser extends Sprite{
		private var _canvas:BitmapData=new BitmapData(512,512,true,0xff000000);
		private var bmp:Bitmap=new Bitmap(_canvas,PixelSnapping.AUTO,true);
		private var bullet:Array;
		private var lArr:Array=new Array(),setObject:Object=new Object();
		private var f:uint,l:uint,i:uint,j:uint,k:uint;
		private var img:Sprite=new Sprite();
		private var filterObj:BlurFilter;
		public function Laser(){
			f=0;
			bullet=new Array();
			bullet[0]=new BitmapData(8,8,true,0x0);
			var g:Graphics=img.graphics;	
			g.beginFill(0xffff80,0.5);
			g.drawCircle(4,4,4);
			g.endFill();	
			g.beginFill(0xffff00);
			g.drawCircle(4,4,2);
			g.endFill();
			bullet[0].draw(img);

			bullet[1]=new BitmapData(8,8,true,0x0);	
			g.clear();
			g.beginFill(0xff80ff,0.5);
			g.drawCircle(4,4,4);
			g.endFill();	
			g.beginFill(0xff60ff);
			g.drawCircle(4,4,2);
			g.endFill();
			bullet[1].draw(img);
			filterObj=new BlurFilter();
			with(filterObj){
				blurX=2;
				blurY=2;
				quality=2;
			}
			addChild(bmp);
			addChild(new Stats());
			addEventListener("enterFrame", loop);
		}
		private function loop(e:Event):void{
			if(f%20==0)createLaser(256,256,0.25,0.05,Math.floor(Math.random()*360),Math.floor(Math.random()*2)*2-1,25,0);
			if(f%30==15)createLaser(256,256,0.25,0.1,Math.floor(Math.random()*360),0,25,1);
			draw()
			f++;
		}
		private function draw():void{
			_canvas.lock();
			l=lArr.length;
			_canvas.applyFilter(_canvas,_canvas.rect,new Point(0,0),filterObj);
			for(i=0;i<l;i++){
				lArr[i].x+=Math.cos(lArr[i].r/180*Math.PI)*lArr[i].v;
				lArr[i].y+=Math.sin(lArr[i].r/180*Math.PI)*lArr[i].v;
				if(Math.abs(lArr[i].x-256)>512||Math.abs(lArr[i].y-256)>512){
					lArr.splice(i,1);
				}
				else{
					lArr[i].v+=lArr[i].a;
					lArr[i].r+=lArr[i].ra;
					lArr[i].arr.unshift(new Point(lArr[i].x-4,lArr[i].y-4));
					lArr[i].arr.pop();
					for(k=0;k<lArr[i].len;k++){
						_canvas.copyPixels(bullet[lArr[i].type],bullet[lArr[i].type].rect,lArr[i].arr[k],null,null,true);
					}
				}
			}
			_canvas.unlock();
		}
		private function createLaser(ox:Number,oy:Number,ov:Number,oa:Number,or:Number,ora:Number,olen:uint,otype:uint):void{
			setObject=new Object();
			setObject.x=ox;
			setObject.y=oy;
			setObject.v=ov;
			setObject.a=oa;
			setObject.r=or;
			setObject.ra=ora;
			setObject.len=olen;
			setObject.type=otype;
			setObject.arr=new Array(setObject.len);
			for(j=0;j<setObject.len;j++){
				setObject.arr[j]=new Point(setObject.x-4,setObject.y-4);
			}
			lArr.push(setObject);
		}
	}
}