dbarbarian
01-13-2006, 04:12 PM
I made two versions. One regular and one rainbow.
Let me know which one you like better, because I can't decide.
The rainbow code is the same as this one, but with different color settings.
EDIT: This code should be legal.
this.headA = new Array();
this.drawCircle = function(col,siz,x,y,d) {
this.createEmptyMovieClip("c"+d,d)._x = x;
this["c"+d]._y = y;
this["c"+d].lineStyle(siz,col,100);
this["c"+d].lineTo(1,0);
return this["c"+d];
}
this.removeParticle = function(n,ind) {
n.removeMovieClip();
this.headA.splice(ind,1);
}
this.onEnterFrame = function() {
for (i in this.headA) {
this.headA[i][0]._x += (this.headA[i][5]!="head2") ? this.headA[i][3]:(this.headA[i][1]-this.headA[i][0]._x)/8;
this.headA[i][0]._y += (this.headA[i][5]!="head2") ? this.headA[i][4]:(this.headA[i][2]-this.headA[i][0]._y)/8;
this.headA[i][0]._xscale = this.headA[i][0]._yscale = (80+random(70)-35);
this.headA[i][2] += (this.headA[i][5]=="head2") ? 2:0;
col = new Color(this.headA[i][0]).setRGB("0xFFFF"+((random(2)==0) ? "FF":((random(2)==0) ? "CC":"99")));
if (this.headA[i][5] == "head" and (this.headA[i][0]._x-this.headA[i][1])*(this.headA[i][0]._x-this.headA[i][1])+(this.headA[i][0]._y-this.headA[i][2])*(this.headA[i][0]._y-this.headA[i][2])<100) {
for(j=0; j<16; j++) {
this.headA.push([this.drawCircle("0xFFFFFF",5,this.headA[i][0]._x,this.headA[i][0]._y,this.d++),this.headA[i][0]._x+((j<8) ? (random(20)+100):(random(10)+55))*Math.cos(j*Math. PI/4+Math.random()*Math.PI/8),this.headA[i][0]._y+((j<8) ? (random(20)+100):(random(10)+55))*Math.sin(j*Math. PI/4+Math.random()*Math.PI/8),0,0,"head2"]);
}
this.removeParticle(this.headA[i][0],i);
} else if (this.headA[i][5] == "head2" and this.headA[i][0].clicks++>20+random(15)) {
this.removeParticle(this.headA[i][0],i);
} else if (this.headA[i][5] == "trail" and this.headA[i][2]-this.headA[i][0]._y<2) {
this.removeParticle(this.headA[i][0],i);
}
(this.headA[i][5]!="trail" and random(2)==0) ? this.headA.push([this.drawCircle("0xFFFFFF",2,this.headA[i][0]._x+random(8)-4,this.headA[i][0]._y+random(8)-4,this.d++),this.headA[i][0]._x,this.headA[i][0]._y+random(20)+5,0,1,"trail"]):0;
}
}
this.onMouseDown = function() {
this.tempx = random(400);
this.headA.push([this.drawCircle("0xFFFFFF",5,this.tempx,415,this.d++),this._xmouse,this._ymo use,7*Math.cos(Math.atan2(this._ymouse-415,this._xmouse-this.tempx)),7*Math.sin(Math.atan2(this._ymouse-415,this._xmouse-this.tempx)),"head"]);
}
*NOTE: Do not click too many times. I recommend having 2 fireworks onscreen at one time.
http://dounanthebarb.tripod.com/Kirupa25LineContest/cdb25LineEntry1Fireworks.html
http://dounanthebarb.tripod.com/Kirupa25LineContest/cdb25LineEntry1RbFireworks.html
****NOTE 2*******
Do NOT view the swf file below. For some strange reason, the particles are not removed. The html files are working correctly though.
Let me know which one you like better, because I can't decide.
The rainbow code is the same as this one, but with different color settings.
EDIT: This code should be legal.
this.headA = new Array();
this.drawCircle = function(col,siz,x,y,d) {
this.createEmptyMovieClip("c"+d,d)._x = x;
this["c"+d]._y = y;
this["c"+d].lineStyle(siz,col,100);
this["c"+d].lineTo(1,0);
return this["c"+d];
}
this.removeParticle = function(n,ind) {
n.removeMovieClip();
this.headA.splice(ind,1);
}
this.onEnterFrame = function() {
for (i in this.headA) {
this.headA[i][0]._x += (this.headA[i][5]!="head2") ? this.headA[i][3]:(this.headA[i][1]-this.headA[i][0]._x)/8;
this.headA[i][0]._y += (this.headA[i][5]!="head2") ? this.headA[i][4]:(this.headA[i][2]-this.headA[i][0]._y)/8;
this.headA[i][0]._xscale = this.headA[i][0]._yscale = (80+random(70)-35);
this.headA[i][2] += (this.headA[i][5]=="head2") ? 2:0;
col = new Color(this.headA[i][0]).setRGB("0xFFFF"+((random(2)==0) ? "FF":((random(2)==0) ? "CC":"99")));
if (this.headA[i][5] == "head" and (this.headA[i][0]._x-this.headA[i][1])*(this.headA[i][0]._x-this.headA[i][1])+(this.headA[i][0]._y-this.headA[i][2])*(this.headA[i][0]._y-this.headA[i][2])<100) {
for(j=0; j<16; j++) {
this.headA.push([this.drawCircle("0xFFFFFF",5,this.headA[i][0]._x,this.headA[i][0]._y,this.d++),this.headA[i][0]._x+((j<8) ? (random(20)+100):(random(10)+55))*Math.cos(j*Math. PI/4+Math.random()*Math.PI/8),this.headA[i][0]._y+((j<8) ? (random(20)+100):(random(10)+55))*Math.sin(j*Math. PI/4+Math.random()*Math.PI/8),0,0,"head2"]);
}
this.removeParticle(this.headA[i][0],i);
} else if (this.headA[i][5] == "head2" and this.headA[i][0].clicks++>20+random(15)) {
this.removeParticle(this.headA[i][0],i);
} else if (this.headA[i][5] == "trail" and this.headA[i][2]-this.headA[i][0]._y<2) {
this.removeParticle(this.headA[i][0],i);
}
(this.headA[i][5]!="trail" and random(2)==0) ? this.headA.push([this.drawCircle("0xFFFFFF",2,this.headA[i][0]._x+random(8)-4,this.headA[i][0]._y+random(8)-4,this.d++),this.headA[i][0]._x,this.headA[i][0]._y+random(20)+5,0,1,"trail"]):0;
}
}
this.onMouseDown = function() {
this.tempx = random(400);
this.headA.push([this.drawCircle("0xFFFFFF",5,this.tempx,415,this.d++),this._xmouse,this._ymo use,7*Math.cos(Math.atan2(this._ymouse-415,this._xmouse-this.tempx)),7*Math.sin(Math.atan2(this._ymouse-415,this._xmouse-this.tempx)),"head"]);
}
*NOTE: Do not click too many times. I recommend having 2 fireworks onscreen at one time.
http://dounanthebarb.tripod.com/Kirupa25LineContest/cdb25LineEntry1Fireworks.html
http://dounanthebarb.tripod.com/Kirupa25LineContest/cdb25LineEntry1RbFireworks.html
****NOTE 2*******
Do NOT view the swf file below. For some strange reason, the particles are not removed. The html files are working correctly though.