Tips on animating an explosion

I’m trying to figure out the best way to animate an explosion in flash…(I’m not too good at it :P)…does anyone have any tips or examples? Thanks in advance =)

http://www.voetsjoeba.com/experiments/fireworks.html ?

that’s pretty cool how exactly did you do that?..obviously with AS…

cool, I want to add gravity to the particles and make lemmings that nuke 3 secs after you click on them! :slight_smile:

lol…

Here’s the script :slight_smile:


d = 0;
dotsize=4
amount = 50;
colors = [0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0x00FFFF];
blast = {inner_radius:130,outer_radius:250,strength:1.1,blisteringFromTarget:50}
fire = {explodeFromTarget:15,strength:1.1}
MovieClip.prototype.makeDot = function() {
	var thiscolor = colors[Math.floor(Math.random()*colors.length)];
	with (this) {
		lineStyle(dotsize, thiscolor, 100);
		lineTo(.45, .15);
	}
};
MovieClip.prototype.calculatePosition = function(nr) {
	var radius = blast.inner_radius+Math.floor(Math.random()*(blast.outer_radius+1));
	var angle = (nr/amount)*(Math.PI*2);
	this.pos = {x:Math.cos(angle)*radius, y:Math.sin(angle)*radius};
};
MovieClip.prototype.easeTo = function(x, y) {
	this.onEnterFrame = function() {
		this._x = x-(x-this._x)/blast.strength;
		this._y = y-(y-this._y)/blast.strength;
		if (this._x>x-blast.blisteringFromTarget && this._x<x+blast.blisteringFromTarget && this._y>y-blast.blisteringFromTarget && this._y<y+blast.blisteringFromTarget) {
			var mx = 100;
			this.onEnterFrame = function() {
				this._alpha = Math.floor(Math.random()*(mx+1));
				mx -= 5;
				if (mx<=0) this.removeMovieClip();
				this._x = x-(x-this._x)/blast.strength;
				this._y = y-(y-this._y)/blast.strength;
			};
		}
	};
};
MovieClip.prototype.fireWorks = function() {
	var m = {x:_root._xmouse, y:_root._ymouse};
	var explodeAt = 15
	this.createEmptyMovieClip("origineel"+MovieClip.originals, d++).makeDot();
	fr = this["origineel"+MovieClip.originals]
	fr.curOrig = MovieClip.originals
	fr._x = m.x
	fr._y = 500
	fr.onEnterFrame = function() {
		this._y = m.y-(m.y-this._y)/fire.strength;
		if (this._y>m.y-fire.explodeFromTarget && this._y<m.y+fire.explodeFromTarget) {
			delete this.onEnterFrame;
			for (i=0; i<=amount; i++) {
				MovieClip.i++;
				mc = this._parent["origineel"+this.curOrig].duplicateMovieClip("dot"+MovieClip.i, d);
				mc._x = m.x;
				mc._y = m.y;
				mc.calculatePosition(i);
				mc.easeTo(m.x+mc.pos.x, m.y+mc.pos.y);
				d++;
			}
			this._parent["origineel"+this.curOrig].removeMovieClip()
		}
	};
	MovieClip.originals++;
};
MovieClip.i = 0;
MovieClip.originals = 0;
this.onMouseDown = function() {
	this.fireWorks();
};

whoa!!! where do put all that?

EDIT: nevermind figured it out…very nice :smiley:

on frame one :wink:

Are there any other techniques…like actual animation maybe?

Yeah you could do that … but it’d take a lot more time.

great code, Voetsjoeba:thumb:
thanks for sharing…

scotty

Thanks scotty :slight_smile:

ok…thanks a lot everyone ;)…