# Create a Real Time Shadow Effect with Actionscript

**URL:** <https://forum.kirupa.com/t/create-a-real-time-shadow-effect-with-actionscript/67916>\
**Category:** flash\
**Created:** [October 20, 2004, 5:43pm UTC](https://forum.kirupa.com/t/create-a-real-time-shadow-effect-with-actionscript/67916 "2004-10-20T17:43:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldob](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/aldob/32/830_2.png) [@aldob](https://forum.kirupa.com/u/aldob)\
**Post date:** [October 20, 2004, 5:43pm UTC](https://forum.kirupa.com/t/create-a-real-time-shadow-effect-with-actionscript/67916/1 "2004-10-20T17:43:48Z")

</div>

yuuu hi,

I want to **attach a shadow to any MC dynamically** with actionscript. Not only for regular shaped clips (rectangles and circles) but also for irregular ones.  
The shadow should also **be able to follow if the original MC resizes or moves** around the stage. Aditionally, the shadow should be able to move and resize in such a way that the **MC appears to gain or loose altitude** (the effect of separation from the stage, or lifing effect). Of course the latter must be coordinated with proper MC scaling.

here is my mind draft for the simplest approach:

- duplicate target\_mc as shadow\_mc
- place shadow\_mc right below target\_mc (with DepthManager)
- apply a color Transform to shadow\_mc and make it totally black
- shadow\_mc.\_alpha = 30 or whatever
- offset shadow\_mc’s position by some pixels
- add a listener to onEnterFrame that coordinates scaling and position between the two clips
- to create the lifing effect, the relation of scaling and position offset must be changed by a factor… and shadow\_mc.\_alpha must be changed inversely to it’s scale.

Now, this technique should work out quite well. It does, actually. But there is one BIG problem with it:  
Some of my target\_mc’s are not easily duplicated. They are complex components that have aquired their appearance through a series of processes. They have moving parts or sections, for example. Or they have members that appear and dissapear (like a context menu with sub menus).

Now, the ideal solution would be to trace the target\_mc’s shape and draw a filled outline with the drawing API, repeating the process on every frame. This is obviously a heavy process… and, how on earth can I trace an MCs boundaries? Maybe by creating a small clip, make it go through the whole area over the movie clip and check for collisions…?

Well, I’m just thinking out loud now…

ActionScript Gamers, please comment!!  
I’m sure someone on this planet has this figured out… 😛  
I am working on it and your ideas are more than welcome!!
