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!!