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-31

Get Adobe Flash player
by plus-tic 31 May 2010
    Embed
/**
 * Copyright plus-tic ( http://wonderfl.net/user/plus-tic )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/yryC
 */

// forked from Takatsukier's forked from: flash on 2010-5-31
// forked from Takatsukier's flash on 2010-5-31
package
{
	import flash.display.Sprite;
	import flash.events.Event;
 
	public class Main extends Sprite
	{
		private var hako:Vector.<Heart> = new Vector.<Heart>();
		private var count:int = 0;
 
		public function Main()
		{
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
 
		private function onEnterFrame(event:Event):void 
		{
			if (count++ % 10 == 0)
			{
				var heart:Heart = new Heart();
				addChild(heart);
				hako.push(heart);
			}
 
			for (var i:int = 0; i < hako.length; i++)
			{
				hako[i].move();
				if (hako[i].alpha < 0.1)
				{
					removeChild(hako[i]);
					hako.splice(i--, 1);
				}
			}
		}
	}
}
 
import flash.display.*;
 
class Heart extends Sprite
{
	public var vx:int = Math.random() * 20 - 10;
	public var vy:int = -(20 + Math.random() * 20);
	public var vz:int = Math.random() * 20 - 10;
	public const RADIUS:int = 15;
	
	public var heart:Sprite = new Sprite();
	public var g:Graphics = heart.graphics;
	
	public function rand(num:Number):Number{
		return Math.random()*num;
	}
 
	public function Heart()
	{
		this.x = 465 / 2;
		this.y = 465;
		this.z = 600;
 		
 		g.lineStyle(138,rand(0xFFFFFF), 1.0,false,LineScaleMode.NORMAL,CapsStyle.ROUND,JointStyle.MITER);
 		
 		g.moveTo(50,50);
 		g.lineTo(100,100);
 		g.lineTo(150,50);
 		
 		addChild(heart);
	}
 
	public function move():void
	{
		vy += 2;
		this.x += vx;
		this.y += vy;
		this.z += vz;
 
		if (vy >= 0 && this.y + rand(RADIUS) >= 465)
		{
			this.y = 465 - RADIUS;
			vy *= -0.9;
 
			this.alpha -= 0.03;
		}
	}
}