Valentine’s Day renderings – programming shadows in ActionScript 3
February 15th, 2009 : Nik RowellI’ve been putting some thought lately into the best way to render shadows in AS3. The built-in DropShadowFilter is perfect for most situations – particularly headlines and simple movie clips – but it lacked perspective control, at least for what I was envisioning…
Here’s the technique I used:
- Created a
BitmapDatainstance, and added it to the display list as aBitmap - Added 500 hearts to a container sprite – drawn programatically with a custom Heart class, similar to the code used in this Processing experiment. Their size and rotation was controlled using Perlin noise – following a random path.
- One the hearts were all drawn … I used the
BitmapData.drawmethod to draw the contents of the container sprite into the BitmapData instance. - I used the
BitmapData.applyFilterto desaturate and apply a slight Blur to the shadow. - Finally, the shadow’s y position and scaleY properties (set when added to the stage) were used to give the shadow a more realistic perspective.
Tags: ActionScript, AS3, Experiments, Flash














