# Help with lost in beta's particle volcano

**URL:** <https://forum.kirupa.com/t/help-with-lost-in-betas-particle-volcano/173979>\
**Category:** Uncategorized\
**Created:** [December 31, 2005, 11:34pm UTC](https://forum.kirupa.com/t/help-with-lost-in-betas-particle-volcano/173979 "2005-12-31T23:34:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)\
**Post date:** [December 31, 2005, 11:34pm UTC](https://forum.kirupa.com/t/help-with-lost-in-betas-particle-volcano/173979/1 "2005-12-31T23:34:28Z")

</div>

Lost did this great particle volcano in the sources/experiments section:  
[http://kirupa.com/forum/showthread.php?t=80014](http://kirupa.com/forum/showthread.php?t=80014)

I am trying to modify it so it only “erupts” when a particular movieclip is clicked. I tried to put the code on said movieclips timeline and changed all path references (there are very few; i’m thinking only the code on the main timeline needs to be changed) but it is still firing off when I click anywhere on the stage.

Any ideas? :hr:

Code on main timeline of lost’s fla:

```auto

//define particle generation variables
var i, rain, pCount = 30, rate = 30;
//function to add a particle on the stage
function addParticle() {
	i++;
	attachMovie('particle', 'particle'+i, i, {_x:275, _y:385}).addGrav();
	if (i>pCount) {
		clearInterval(rain);
	}
}
//function to clear all existing particles from the stage
function clearParticles() {
	clearInterval(rain);
	for (var clip in _root) {
		_root[clip].removeMovieClip();
	}
}
//function to reset and generate new particles when mouse is clicked
this.onMouseDown = function() {
	clearParticles();
	i = 0;
	rain = setInterval(addParticle, rate);
};

```

Code on particle that is attached from library:

```auto

#initclip
//define particle restrictions
var restrictions = {left:0, right:550, top:0, bottom:400};
//define physics variables
var grav = 2, drag = .98, bounce = .9, rot = 5;
function Particle() {
	this._xscale = this._yscale=Math.random()*(100-5)+5;
	this.aFade = Math.random()*(3-1)+1;
	this.xspeed = Math.random()*30-15;
	this.yspeed = Math.random()*-60;
}
Particle.prototype = new MovieClip();
Object.registerClass("particle", Particle);
Particle.prototype.onEnterFrame = addGrav;
function addGrav() {
	this._x = this._x+this.xspeed;
	if (this._x+this._width/2>restrictions.right) {
		this._x = restrictions.right-this._width/2;
		this.xspeed = -this.xspeed*bounce;
	}
	if (this._x-this._width/2<restrictions.left) {
		this._x = restrictions.left+this._width/2;
		this.xspeed = -this.xspeed*bounce;
	}
	this._y = this._y+this.yspeed;
	if (this._y+this._height/2>restrictions.bottom) {
		this._y = restrictions.bottom-this._height/2;
		this.yspeed = -this.yspeed*bounce;
	}
	if (this._y-this._height/2<restrictions.top) {
		this._y = restrictions.top+this._height/2;
		this.yspeed = -this.yspeed*bounce;
	}
	this.yspeed = this.yspeed*drag+grav;
	this.xspeed = this.xspeed*drag;
	if (Math.floor(this.yspeed) == 1) {
		this._alpha -= this.aFade;
		if (this._alpha<1) {
			this.removeMovieClip();
		}
	}
	this._rotation += this.xspeed*rot;
}
#endinitclip

```
