Super Stupidly Simple Particle Effect (Actionscript 3.0)

Here’s a quick particle effect I threw together. Thought I’d put it up here… figuring it might help some hapless googler searching for a quick fix, since it’s a super simple class you can easily reuse or (quite possibly) extend… probably.
Download source here.

Mouse over the above area to preview.

The AS (


	import flash.utils.Timer;
	import flash.geom.Point;
	import flash.display.MovieClip;

	public class Particle extends MovieClip

		protected var position:Point;
		protected var vector:Point;
		private var gravity:int;
		private var friction:Number;
		private var maxIterationsAlive:Number;
		private var iterationsAlive:Number;
		protected var update_i:Timer;

		public function Particle(p:Point, v:Point, g:int, f:Number)
			position = p;
			vector = v;
			gravity = g;
			friction = f;
			maxIterationsAlive = 10;
			iterationsAlive = 0;

			update_i = new Timer(25);

			update_i.addEventListener(TimerEvent.TIMER, update);

		public function update(evt:TimerEvent):void
			if (iterationsAlive > maxIterationsAlive) {
				update_i.removeEventListener(TimerEvent.TIMER, update);

			//the * 10  determines what direction it shoots out of - in this case the side
			position.x +=  vector.x + Math.random() * 10; 
			position.y +=  vector.y + Math.random() * 10;

			vector.y +=  gravity;
			vector.x *=  friction;
			//apply positions to the clip
			x = position.x;
			y = position.y;
			alpha -= .01; //fade


And simply link it to a movieclip instance:

Particle Effect Linkage

There! A stupid simple particle effect.

Visit the sourcefiles directory here.

This monster belongs in Web/Game Dev: Tutorials & Sourcecode. Bookmark the permalink. Follow any flames or other attacks to it with the RSS feed for this abominable creature. Voice your rage or leave a /b/roback: /b/roback URL.

Post a /B/romment

Chill, /b/ro. Your email is probably not, but most likely impossibly going to be not shared. Required fields are marked, yo... *


Use these /b/ro HTML haxxx: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>