The 'Nova' Effect

The interactive 'cosmic' particle effect presented here is the next one in our series of particle experiments. Among previous installments see, for example: Rain with Splashing Raindrops or A Dynamic, Interactive Fountain. Click on the image below to open the 'Nova' Flash movie.



We’ve been having so much fun with particle animations lately that we’ve decided to put another one together, using the same core code as in our previous examples. Here the particles take the form of tiny disks that emit from a central location. A blur filter creates an effect reminiscent of a celestial event.

The particles grow in size and fade out gradually. This is accomplished by means of “envelope” parameters controlling the evolving size of the disks, a method we have used previously in our Ribbons and Lorenz Bubbles examples.

The colors of the particles change gradually. After a lot of experimentation, we settled on a coloring method that allows for a wide range of bright colors which change slowly, but with some randomness so that the movie will be unique each time you view it. The method is as follows. The particle colors are randomly chosen, but with values near a slowly changing “base” color. This base color is created from red, green, and blue components which change over time according to three different sinusoidal functions with fixed frequencies. To add some randomness, the phase of each sinusoid is changed over time gradually to target values which are chosen randomly at regular intervals. Thus the sinusoidal functions provide a rather consistent change in color while the phase shift allows for randomness.

To add interactivity, we have made the particles to be attracted to the mouse position. The acceleration towards the mouse is set according to an “inverse square” force, which simulates gravitational attraction. Clicking on the display will turn the mouse attraction on and off. Adding this interaction was quite easy due to the class structure. Each particle has acceleration and velocity properties which are used to determine its motion in the particle display class. Adding gravitational attraction is accomplished simply by setting the acceleration of each particle directly and allowing the display class to handle the motion and animation of the particles.

Back to Flash CS4 Tutorials              Back to Flash and Math Home

We welcome your comments, suggestions, and contributions. Click the Contact Us link below and email one of us.

Adobe®, Flash®, ActionScript®, Flex® are registered trademarks of Adobe Systems Incorporated.