Wanted to take a break from a larger project I’m working on, so this morning I made a wind effect. No real reason outside of having a distraction. It works on any display object, and has several properties to control how the effect looks. Accessors include:
[LIST]
[]emitter: The source of the wind (point)
[]speed: The strength of the wind
[]variance: Variance of the wind’s speed
[]behavior: “fixed” and “grow” are the options. Either the wind blows out to a fixed radius, or it carries across the screen indefinitely
[]radius: If “fixed” is the behavior, then radius defines how far out the wind reaches.
[]friction: Once a particle is outside of the wind’s area of effect, friction controls its slowdown rate.
[*]smear: Leaves a trail as particles are pushed about, looking like smears or magnetic particulate matter collecting.
[/LIST]There are 3 methods: blow(), stop() and reset(). Should be pretty obvious.
Instantiation is done by passing the display object in the constructor then adding to the stage.
var wind:WindEffect = new WindEffect(someDO);
addChild(wind);
Real small class (and a throwaway particle class), along w/ a SWF example. The example uses the mouse, but it’s just as easy to animate through code by controlling the wind emitter or automate using the class’s “grow” behavior. Throws a complete event when all particles are off the screen if you like that sort of thing. Not much else to say, it’s a simple class. Enjoy!