Basic Particle System
This tutorial will teach you how to create a very simple particle system in flash.
1) First, we need to draw something that we will be duplicating. A dot, space ship asteriod. It's up to you. I will be making some falling snow, so I am just going to draw a dot.
2) Next, we need to make it a Movie Clip. Simply highlight what you just drew, and hit F8. Make sure it is set to 'Movie Clip' and type in particle for the name. Your menu should look something like this:

3) Now, click on your newly created movie clip, go down to the 'Properties' box and set the instance name to particle.
4) Open up your 'Actions' window (f9), and add this code to the movieclip:
I will break this code down now.
This says, when the movie loads, assign this movie clips x (horizontal) value from 0-320. Assign this movie clips y (vertical) value to a number from 0-240. Assign a random value to the variable 'speed'. And last it assigns a random value to the variable 'variation'.
This says, when the movie enters this frame (which it will loop through) that it should add the value that we assigned to speed (random) to the vertical position of the movie clip. Then it says add the value we assigned 'variation' to the movie clips horizontal position. Then it says, if the vertical position is greater than the hieght of your movie (in my case it's 240) then it will reset the particle to the top of the stage. It does the same for the horizontal position, if it goes off of the left of the stage, it will get reset to the right side.
5) If you hit control and enter right now, you should have one particle that will float off screen, and reapear. Now we will duplicate this movie clip. Make a new layer, call it 'Actions' and add this code to the first frame:
This sets the value 100 to the variable 'numPart'.
This, simplified, says that it will create new movie clips with new names and depths, until it reaches the number we assigned 'numPart' (100).
6) You're done now, and you have your simple falling snow. You can go back and edit things if you wish, just play around with some values we gave the variables. You can apply this to an inumerable ammount of games or programs you wish to create.
Click here to download the *.fla
1) First, we need to draw something that we will be duplicating. A dot, space ship asteriod. It's up to you. I will be making some falling snow, so I am just going to draw a dot.
2) Next, we need to make it a Movie Clip. Simply highlight what you just drew, and hit F8. Make sure it is set to 'Movie Clip' and type in particle for the name. Your menu should look something like this:

3) Now, click on your newly created movie clip, go down to the 'Properties' box and set the instance name to particle.
4) Open up your 'Actions' window (f9), and add this code to the movieclip:
Code:
onClipEvent (load) {
this._x = Math.random()*320;
this._y = Math.random()*240;
speed = Math.floor(Math.random()*3)+6;
variation = Math.floor(Math.random()*6)+1;
}
onClipEvent (enterFrame) {
this._y += this.speed;
this._x += this.variation;
if (this._y > 240) {
this._y = 0;
}
if (this._x > 320) {
this._x = 0;
}
}
Code:
onClipEvent (load) {
this._x = Math.random()*320;
this._y = Math.random()*240;
speed = Math.floor(Math.random()*3)+6;
variation = Math.floor(Math.random()*6)+1;
}
Code:
onClipEvent (enterFrame) {
this._y += this.speed;
this._x += this.variation;
if (this._y > 240) {
this._y = 0;
}
if (this._x > 320) {
this._x = 0;
}
}
5) If you hit control and enter right now, you should have one particle that will float off screen, and reapear. Now we will duplicate this movie clip. Make a new layer, call it 'Actions' and add this code to the first frame:
Code:
numPart = 100;
for ( var index = 0; index < numPart; index++) {
particle.duplicateMovieClip("particle"+index, index);
}
Code:
numPart = 100;
Code:
for ( var index = 0; index < numPart; index++) {
particle.duplicateMovieClip("particle"+index, index);
}
6) You're done now, and you have your simple falling snow. You can go back and edit things if you wish, just play around with some values we gave the variables. You can apply this to an inumerable ammount of games or programs you wish to create.
Click here to download the *.fla
