Particles, those things where you create a firework like effect with actionscript. They can be scary to some who are new to flash, but are fun for both new and ex[perienced flash users, they are also very simple to make. This tutorial will go over the basics of creating particles and then also cover a few ways to make them more interesting. Lets get Started.
First off open up flash and create a new flash file. stage size and background are not important so just pick something you feel like, or leave as your default settings, However the values used for certain variables in this tutorial are based of a 24fps file. so play around with and adjust frame rate and or variable values as you see fit to best suit your needs.
Ok now to take care of the only art that you really need, a circle. Just grab your circle tool and draw yourself a small ball. (note: you can actualy draw whatever shape you want. but for this tutorial we will just keep it simple and generic so a cirlce will do)
Convert this circle into a movie clip(MC) using the hotKey F8 or using modify>convert to symbol. TGive it the name particle_art (or similar). Now with the movie clip selected on stage convert to a MC again creating a MC within another MC, call this movie clip particle_whole (or similar) with this clip select export to actionscript and if you want you can give it a shorter identifier name as long as you remember it.
(Note: i used p as the identifier for this tutorial)
Now for the actions. Double click on the particle_whole MC and then select the particle_art clip within it. Open your actions window with the F9 key and type in the following code.
1
2
3
4
5
6
7
8
9
10
11
12
| onClipEvent (load) {
gravity = 1;
friction = 0.98;
yvel = (Math.random()*20)-15;
xvel = (Math.random()*20)-10;
}
onClipEvent (enterFrame) {
_parent._x += xvel;
_parent._y += yvel;
yvel += gravity;
xvel *= friction;
} |
On the next page I will break down this code and explain what it does.