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: forked from: flash on 2010-5-15

/**
 * Copyright h_sakurai ( http://wonderfl.net/user/h_sakurai )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7JJs
 */

// forked from uwi's forked from: flash on 2010-5-15
// forked from tebasak_i's flash on 2010-5-15
package {
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.utils.Timer;
	import flash.events.Event;
	
	import frocessing.color.*;
	[SWF(width="465", height="465", backgroundColor="0", frameRate="30")]
    public class FlashTest extends Sprite {
		private var hanabi:Array = new Array();
		private var hanabi1:Array = new Array();
		private var color:Array = new Array();
		private var size:Array = new Array();	
		private var hankei:Array = new Array();
		private var takasa:Array = new Array();
		private var hanabi_x:Array = new Array();
		private var hanabi_to:Array = new Array();
		private var hanabiStatus:Array = new Array();
		private var speed:Array = new Array();
		private var timer:Timer;
		private var numHanabi:Number = 100;
        public function FlashTest() {
			fw();
		}
		public function fw():void{
			var colors:Number = 0;
			var sizes:Number = 0;
			var hankeis:Number = 0;
			var takasas:Number = 0;
			var hanabi_xs:Number = 0;
			var statuses:String = "launch";
			
			var cc : ColorHSV = new ColorHSV();
			for(var i:Number = 0; i<numHanabi; i++){
				var speeds:Number = Math.random() * 2;
				speed.push(speeds);
				hanabiStatus.push(statuses);
				cc.hsv(Math.random() * 360, Math.random() * 0.5 + 0.5, 1);
				colors = cc.value;
//				colors = 0xFFFFFF * Math.random();
				color.push(colors);
				sizes = 1 + 4 * Math.random();
				size.push(sizes);
				hankeis = 15 + 15 * Math.random();
				hankei.push(hankeis);
				takasas = stage.stageHeight / 2 * Math.random();
				takasa.push(takasas);
				hanabi_xs = stage.stageWidth * Math.random();
				hanabi_x.push(hanabi_xs);
				hanabi.push(new Sprite());
				hanabi1.push(new Array());
				hanabi_to.push(new Array());
				hanabi[i].graphics.lineStyle(3,colors);
//				hanabi[i].graphics.beginFill(colors);
				hanabi[i].graphics.drawCircle(0,0,sizes);
//				hanabi[i].graphics.endFill();
				hanabi[i].x = hanabi_x[i];
				hanabi[i].y = stage.stageHeight + stage.stageHeight * Math.random();
				hanabi[i].blendMode = "add";
				addChild(hanabi[i]);

				for(var j:Number=0; j<12; j++){
					hanabi1[i].push(new Sprite());
					hanabi1[i][j].graphics.lineStyle(3,color[i]);
//					hanabi1[i][j].graphics.beginFill(color[i]);
					hanabi1[i][j].graphics.drawCircle(0,0,size[i]);
//					hanabi1[i][j].graphics.endFill();
					hanabi1[i][j].x =  hanabi[i].x;
					hanabi1[i][j].y =  takasa[i];
					hanabi_to[i].push(new Point());
					hanabi_to[i][j].x =  hanabi[i].x + hankei[i] * Math.PI*2*Math.cos(360/12*j/180*Math.PI);
					hanabi_to[i][j].y =  takasa[i] + hankei[i] * Math.PI*2*Math.sin(360/12*j/180*Math.PI);
					hanabi1[i][j].alpha = 0;
					hanabi1[i][j].blendMode = "add";
					addChild(hanabi1[i][j]);
				}
			}
			
			graphics.beginFill(0x000000);
			graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			graphics.endFill();
			
			addEventListener(Event.ENTER_FRAME, loop);
		}
		
		public function loop(event:Event):void{
			for(var i:Number=0; i<numHanabi; i++){
				if(hanabiStatus[i] == "launch"){
					hanabi[i].y += (takasa[i] - hanabi[i].y) / 5*speed[i] - 5;
					if((hanabi[i].y - takasa[i]) < 1){
						hanabiStatus[i] = "spark";
						for(var l:Number=0; l<12; l++){
							hanabi1[i][l].alpha = 1;
							hanabi1[i][l].x = hanabi[i].x;
							hanabi1[i][l].y = hanabi[i].y;
						}
						hanabi[i].x = hanabi_x[i];
						hanabi[i].y = stage.stageHeight + stage.stageHeight * Math.random();
						takasa[i] = stage.stageHeight / 2 * Math.random();
						speed[i] = Math.random() * 2;
					}
				}else if(hanabiStatus[i] == "spark"){
					for(var j:Number=0; j<12; j++){
						hanabi1[i][j].x+=(hanabi_to[i][j].x-hanabi1[i][j].x)/20;
						hanabi1[i][j].y+=(hanabi_to[i][j].y-hanabi1[i][j].y)/20;
						hanabi1[i][j].alpha -= 0.05;
						if(hanabi1[i][j].alpha < 0.05){
							hanabi1[i][j].alpha = 0;
							hanabiStatus[i] = "launch";
						}
					}
				}
			}
		}
	}
}