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 alterna_in 25 Dec 2009
    Embed
/**
 * Copyright alterna_in ( http://wonderfl.net/user/alterna_in )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/c1KR
 */

//パーティクルってよくわからないけどつくってみた。
package  
{
	import flash.events.Event;
	import flash.display.Sprite;

	/**
	 * @author Toshiki Izumi
	 */
	public class Main extends Sprite
	{

		public function Main()
		{
			init();
		}

		private function init() : void
		{
			addEventListener(Event.ENTER_FRAME, enterFrameHandler);
		}

		private function enterFrameHandler(event : Event) : void
		{
			var perticle : Perticle = new Perticle(Math.random() * 500, Math.random() * 400);
			perticle.draw(0xFF0000, 1, 5);
			perticle.x = mouseX;
			perticle.y = mouseY;
			addChild(perticle);
		}
	}
}

import flash.events.Event;
import flash.display.Sprite;


class Perticle extends Sprite
{

	public var _vx : Number;
	public var _vy : Number;

	public function Perticle(vx : Number = 0,vy : Number = 0)
	{
		_vx = vx;
		_vy = vy;
		addEventListener(Event.ENTER_FRAME, enterFrameHandler);
	}

	public function draw(color : int, alpha : Number, size : Number) : void 
	{
		graphics.beginFill(color, alpha);
		graphics.drawCircle(0, 0, size);
		graphics.endFill();
	}

	private function enterFrameHandler(event : Event) : void
	{
		x += (_vx - x) * 0.3;
		y += (_vy - y) * 0.3;
		alpha += (0 - alpha) * 0.1;
	}
}