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 Susisu 20 Feb 2010
    Embed
/*
 * シャボン玉っぽい何か
 * やたらと適当ですがご了承ください
 */
package {
	import flash.display.Sprite;
	import flash.events.Event;
	[SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="30")]
	public class bubble extends Sprite {
		private var xpos:Number,ypos:Number,xspd:Number,yspd:Number;
		private var r:Number=60;	//半径
		public function bubble() {
			xpos=Math.floor(Math.random()*465-2*r)+r;
			ypos=Math.floor(Math.random()*465-2*r)+r;
			var t:Number=Math.floor(Math.random()*360);
			xspd=Math.cos(t/180*Math.PI)*3;
			yspd=Math.sin(t/180*Math.PI)*3;
			draw();
			addEventListener(Event.ENTER_FRAME,loop);
		}
		private function loop(e:Event):void {
			xspd+=Math.random()*0.1-0.05;
			yspd+=Math.random()*0.1-0.05;
			xpos+=xspd;
			ypos+=yspd;
			if(xpos<0+r)xspd+=0.2;
			if(ypos<0+r)yspd+=0.2;
			if(xpos>465-r)xspd-=0.2;
			if(ypos>465-r)yspd-=0.2;
			draw();
		}
		private function draw():void{
			graphics.clear();
			graphics.lineStyle(1,0x000000,100);
			var xt:Number;
			var yt:Number;
			xt=xpos+r;
			yt=ypos;
			xt=(xt<0?0:xt)>465?465:xt;
			yt=(yt<0?0:yt)>465?465:yt;
			graphics.moveTo(xt,yt);
			for(var i:uint=1;i<=360;i++){
				xt=xpos+Math.cos(i/180*Math.PI)*r;
				yt=ypos+Math.sin(i/180*Math.PI)*r;
				xt=(xt<0?0:xt)>465?465:xt;
				yt=(yt<0?0:yt)>465?465:yt;
				graphics.lineTo(xt,yt);	
			}
		}
	}
}