Help with particles

I’m trying to make a basic particle system and am running into a pretty simple problem I just can’t seem to find the answer to. For some reason none of the particles are moving. Here is my basic code just to start:

onClipEvent (enterFrame) {
i = 0;
totalParticles = 10;
gravity = 1;
}
onClipEvent (enterFrame) {
for (i; i<totalParticles;i++) {
attachMovie (“particle”, “particle” + i, i);
_root.emitter[“particle”+i].xSpeed = random(5);
_root.emitter[“particle”+i].ySpeed = -5;
_root.emitter[“particle”+i].onEnterFrame = function () {
ySpeed = ySpeed + gravity;
this._x += xSpeed;
this._y += ySpeed;
}
}
}

I’m sure the answer is pretty easy I just can’t seem to see it. Thanks in advance.

Fixed :

 
onClipEvent (**load**) {
 i = 0;
 totalParticles = 10;
 gravity = 1;
}

onClipEvent (enterFrame) {
 for (i; i<totalParticles;i++) {
  **_root.emitter.**attachMovie ("particle", "particle" + i, i);
  _root.emitter["particle"+i].onEnterFrame = function () {
**   xSpeed = random(5);
   ySpeed = -5;**
   ySpeed = ySpeed + gravity;
   this._x += xSpeed;
   this._y += ySpeed;
  }
 }
}

use this code only:


onClipEvent(load)
{
	var totalParticles = 10;
	var gravity = 1;
	
	for (var i = 0; i < totalParticles; i++) 
	{
		attachMovie ("particle", "particle" + i, i);
		_root.emitter["particle"+i].xSpeed = random(5);
		_root.emitter["particle"+i].ySpeed = -5;
		
		_root.emitter["particle"+i].onLoad = function()
		{
			var xSpeed = 0;
			var ySpeed = 0;
		}
		
		_root.emitter["particle"+i].onEnterFrame = function () 
		{
			this.ySpeed = this.ySpeed + gravity;
			this._x += this.xSpeed;
			this._y += this.ySpeed;
		}
	}
}

-Jake

also random(number) is a depreciated function. use this to achieve the same effect:


_root.emitter["particle"+i].xSpeed = Math.random() * 5

Here is my version, with dragging and bouncing particles!

http://roy.wigginsworld.org/Particle System.fla

link doesn’t work?

ah I got it. Looks cool!

-jake

Its because I was too lazy to tell the forum the whole thing was a link, and I forgot whatever the “code” for a space was… anyway, I’m glad you like it.

%20 = space

Ah, right.

hi dunga, I can’t find your fla in your site
by the way cool animation