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 bou_Ujin 18 Mar 2010
/**
 * Copyright bou_Ujin ( http://wonderfl.net/user/bou_Ujin )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2iZb
 */

/*
	数年前に作ったもの
	いろいろ試行錯誤していたので、
	使ってない変数・関数、二度手間な処理などが多々あります。
*/
package
{
	import flash.display.*;
	import flash.filters.*;
	import flash.events.*;
	import flash.ui.*;
	import flash.utils.*;
	import flash.geom.*;
	import flash.text.*;
	[SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="60")]
	public class StartSprite extends Sprite
	{
		private var FT:Number;
		private var time:Number;
		private var nyuuryoku:Sprite;
		
		
		private var totalTime:Number=0;
		
		public var maxy:Number=0;
		
		public function StartSprite():void
		{
			/////////////システム関連///////////////////
			addEventListener(Event.ENTER_FRAME,onEnterFrame);
			
			nyuuryoku=new Sprite()
			nyuuryoku.addEventListener(MouseEvent.MOUSE_UP,mouseUpGet);
			nyuuryoku.graphics.beginFill(0x000000);
			nyuuryoku.graphics.drawRect(0,0,475,485);
			nyuuryoku.graphics.endFill();
			addChild(nyuuryoku);
			nyuuryoku.stage.focus=nyuuryoku;
			///////////////////////////////////////////
			
			for(var i:int=0;i<100;i++)
			{
				var bom:bomClass=new bomClass(465*Math.random(),-465*Math.random(),Math.random()*Math.PI,50,this);
			}

			time=getTimer();
			FT=1/60;
			x=-5;
		}
		
		private function onEnterFrame(evt:Event):void
		{
			totalTime+=FT;
			maxy=Math.max(maxy,bomClass.taskshori(FT));
			/*
			var j:Number=getTimer();
			FT=(j-time)/1000;
			time=j;*/
		}
		
		
		private function mouseUpGet(evt:MouseEvent):void
		{
			var A:Array=bomClass.taskA;
			var d:int=A.length;
			for(var i:int=0;i<d;i++)
			{
				A[i].bomed(mouseX,mouseY,60000);
				A[i].bomed(mouseX+475,mouseY,60000);
				A[i].bomed(mouseX-475,mouseY,60000);
			}
		}
		
	}
}

import flash.display.*;
import flash.geom.*;


class MoveClass
{


	//移動関係
	public var XA:Number=0;//相対加速度
	public var YA:Number=0;
	public var XV:Number=0;//相対速度
	public var YV:Number=0;
	public var VP:Point=new Point(0,0);//絶対速度
	public var rad:Number=0;
	private var slowDownX:Number=0.5;
	private var slowDownY:Number=0.5;

	public var scroolX:Number=0;
	public var scroolY:Number=0;

	public function MoveClass(VX:Number,VY:Number,SDX:Number=0.5,SDY:Number=0.5):void
	{
		XV=VX;
		YV=VY;
		
		
		slowDownX=SDX;
		slowDownY=SDY;
	}

	//初期化
	private function Init():void
	{
	}

	public function DStaticRotat(r:Number):void
	{
		//回転による速度補正
		var x0:Number=XV;
		var y0:Number=YV;
		var r0:Number=r-rad;
		XV=x0*Math.cos(r0)+y0*Math.sin(r0);
		YV=-x0*Math.sin(r0)+y0*Math.cos(r0);
			rad=r;
	}
	public function DDynamicRotat(r:Number):void
	{
		DStaticRotat(rad+r);
	}
	
	public function DynamicTrans(FT:Number):void
	{
		
		//変換
		VP.x=(XV*Math.cos(rad)-YV*Math.sin(rad))*FT;
		VP.y=(XV*Math.sin(rad)+YV*Math.cos(rad))*FT;
	}
	public function StaticTrans(FT:Number):void
	{
		//変換
		VP.x=XV*FT;
		VP.y=YV*FT;
	}
	
	public function accel(FT:Number):void
	{
		//加速と減退
		XV+=(XA-slowDownX*XV)*FT;
		YV+=(YA-slowDownY*YV)*FT;
	}
	
}

class bomClass extends MoveClass
{
	public var onEnterFrame:Function;
	
	private var hitF:Boolean=false;
	private var kyara:Shape;
	private var RP:Number=(Math.random()-0.5)*Math.PI;
	private var fire:Number=50;
	private var taskID:int;
	
	public static var taskA:Array=new Array();
	
	
	public function bomClass(X0:Number,Y0:Number,R0:Number,F0:Number,DOC:DisplayObjectContainer):void
	{
		kyara=new Shape();
		super(0,-100,50,5);
		kyara.graphics.lineStyle(1,0xFF8040);
		kyara.graphics.beginFill(0x80FF40);
		kyara.graphics.moveTo(-1,-5);
		kyara.graphics.curveTo(-3,0,-1,5);
		kyara.graphics.lineTo(1,5);
		kyara.graphics.curveTo(-1,0,1,-5);
		kyara.graphics.lineTo(-1,-5);
		//kyara.graphics.drawRect(-1,-5,2,10);
		kyara.graphics.endFill();
		DOC.addChild(kyara);
		kyara.x=X0;
		kyara.y=Y0;

		DStaticRotat(R0);
		fire=F0;
		
		
		YA=465*Math.cos(rad);
		XA=465*Math.sin(rad);
		
		taskID=taskA.push(this);
	}
	
	public function main(FT:Number):Number
	{
		
		
		DynamicTrans(FT);
		
		var obj:Object;
		var x0:Number=kyara.x;
		var y0:Number=kyara.y;
		YA=465*Math.cos(rad);
		XA=465*Math.sin(rad);
		accel(FT);
		RP+=(-YV/40-0.2*RP)*FT;
		DStaticRotat(rad+RP*FT);
		hitF=false;
		kyara.rotation=rad/Math.PI*180;
		kyara.x=(kyara.x+VP.x+475)%475;
		kyara.y+=VP.y;
		
		if(kyara.y>475)
		{
			kyara.y-=485;
			//RP=(Math.random()-0.5)*Math.PI;
			//rad=0;
		}
		
		return kyara.y
	}
	
	public function bomed(X0:Number,Y0:Number,F:Number):void
	{
		var p0:Point=new Point(kyara.x-X0,kyara.y-Y0);
		var d:Number=p0.length;
		XV+=(p0.x/d*Math.cos(rad)+p0.y/d*Math.sin(rad))*F/d;
		YV+=(-p0.x/d*Math.sin(rad)+p0.y/d*Math.cos(rad))*F/d;
	}
	//削除
	private function remove():void
	{
		kyara.parent.removeChild(kyara);
	}

	//タスク処理関連
	public static function taskshori(FT:Number):Number
	{
		var A:Array=taskA;
		var d:int=A.length;
		var maxy:Number=0;
		for(var i:int=0;i<d;i++)
		{
			maxy=Math.max(maxy,A[i].main(FT));
		}
		return maxy;
	}
	public static function removeTask(RN:int):void
	{
		var l:int=taskA.length-1;
		taskA[RN].remove();
		taskA[RN]=taskA[l];
		taskA.pop();
	}

}