Search code examples
actionscript-3maskvector-graphics

actionscript: creating a soft mask using vector shape


I have an hourglass like vector shape and I'd like to use it to mask an image. I'd like to feather the edges - have a soft falloff in transparency that follows the contours of the hour glass. Any ideas how I can do this?

I tried using a gradient fill on a closed shape (using beginGradientFill() and curveTo() functions) but that falloff doesn't follow the contour of the vector shape, it can only go one direction.


Solution

  • Maybe there is a better solution but until somebody comes up with it... I assume you could do the following:

    1. Draw whatever shape you want to use as mask into a transparent bitmap.
    2. Scale a bit the bitmap down (or use a matrix while drawing its bitmapdata).
    3. Apply a blur filter to it.
    4. Put the bitmap's center to the masked clip's center so they are aligned.
    5. Set the masked clip's cacheAsBitmap property to true.