Flash CS3 Particle Effect Tutorial
7. Randomize the size and opacity. Randomizing the size and opacity of our particles involves just a couple simple lines of code that we’re going to add to our addParticle function. Here is the code:

As you can see, the only new code here is on lines 9 and 10. In line 9, we’re randomizing the opacity so that it results in a number between 0.2 and 1.0. This will result in an opacity level anywhere from 20% to 100%.
On line 10, we’re randomizing the scaleX and scaleY properties in order to change the size of the particle.
Oh, and one more thing! If you want your particle effects to run smoothly, it’s a good idea to tell Flash to cache your movie clips as bitmaps. This will significantly improve the performance of your effect. To do this, simply insert the following line of code somewhere around line 15:
dot.cacheAsBitmap = true ;
The final result should look something like this:
So, as you can see, by making just 2 small changes (randomizing the size and opacity), we were able to transform this from a bland, monotonous effect into something beautiful and organic.
Anyways, I hope you enjoyed this tutorial. And I hope you’ll take the time to play around with these setting a little bit to try to achieve different results. Part of the fun of creating particle effects is experimenting with them and trying out different settings. So play around a little bit, and if you come up with something interesting, please email the results in a zip file to craig {at} schoolofflash.com.
Here is the FLA file used in this tutorial: particles.zip
Tags: Flash Tutorial, particle effect
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.




March 12th, 2008 at 8:23 am
Thank you. Very nice tutoring style - clean, coherent, well worded.
IB
March 13th, 2008 at 10:14 pm
[…] Flash CS3 Particle Effect Tutorial […]
March 16th, 2008 at 8:37 am
good day!
first of all, thnx for this wonderful tutorial…
i wonder how to make this particle effect as mask of my pictures…coz i wanted this effect as the transitions of my photo gallery…could someone help me with this?
March 18th, 2008 at 6:27 pm
I’ve been working on an open source particle engine aimed at designers. It lets you create effects like this (and even more complex behaviors) through an interactive particle explorer without writing any Actionscript.
http://www.rogue-development.com/pulseParticles.html
March 20th, 2008 at 11:03 pm
G’Day Craig,
Mate, I’ve been playing with Flash for about 9 months, and only got enough courage to start playing with actionscript about 6 months ago. I struggled for about 3 months and then went off it.
Then about 1 month ago I stumbled over your video tutorials and they just make it all so clear and simple. I have only two days ago upgrade from V8 to CS3 (i.e. actionscript 2 to actionscript 3). I have only had a small taste of whats to come, have been watching your tutorials on AS3 now. Loving every minute of it.
Anyways, just thought you deserve a rap for your efforts.
Thanks.
April 2nd, 2008 at 2:21 pm
This a great effect that has tons of potential.
April 8th, 2008 at 2:42 pm
Let me just say that this is the most thorough Flash tutorial that I’ve ever attempted. Thanks a bunch for the post…this site is going into favorites list immeditealy!
April 17th, 2008 at 2:23 am
This was great. Please make more tutorials as this was the only one I could follow on the web!!
April 28th, 2008 at 8:22 am
Hi Craig,
I finished your tutorial (great btw) but I was wondering if you could tell me how to control the positioning with your cursor? Thanks!
May 7th, 2008 at 12:25 pm
Great tutorial
and if I can help a bit to answer Cynthia Schmutz question.
To control it with mouse you just need to modify 2 lines in the addParticle function:
dot.x = mouseX;
dot.y = mouseY;
Im No an expert since I only have 5 days of experience but it works.
May 24th, 2008 at 7:31 am
Its a very good tutorial But I would like to know, if it is possible to stream .asx radiostations in flash cs3.
Thanks a lot
June 7th, 2008 at 5:37 am
Does anyone know how this could be altered to allow 4 different colours?
Cheers.
June 12th, 2008 at 1:46 pm
I used your particle effect tutorial its great thanks. I tweaked mine and added this:
dot.x = mouseX;
dot.y = mouseY;
How can I make this so that when you mouse over a link the particles don’t interfere with clicking the link?
July 2nd, 2008 at 1:39 am
Can this thing be done in Action Script 2.0? Me and many of my friends want to know this. While dooing it in Action Script 3.0 many of my friends getting error like “playerglobal.swc is missing”. How can this be solved?
July 26th, 2008 at 11:26 am
Very clean and simple effect, I like it
August 6th, 2008 at 3:37 am
I got the following error when i run it in my application:
TypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht möglich.
at bg_partikel_fla::disco_4/addParticle()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
disco is the movieclip in which i placed the as.
Thanks for help
August 17th, 2008 at 11:26 am
[…] Read more […]