Grayscale and Alpha Mask in Actionscript
I would like to make a mask that both converts any colors to grayscale and then reduces their alpha value. The intended purpose is for the masked region to be in grayscale and lighter so that the unmasked region is more prominent. Most tutorials I've seen for alpha value masks are far too complicated and use the Flash GUI. How do you accomplish the same thing in ActionScript?
Update: Here's an explanation with pictures...
If 开发者_运维知识库the following is my image:
Then a traditional mask over some selection would produce the following:
Instead, those parts that are masked out completely, I would like for those to be converted to grayscale:
And their alpha value decreased, so they're lightened:
My recommendation :
- Create an instance of Sprite / Movieclip you want to mask over as a BitmapData object
- Create a Mask instance that you apply to the Sprite Movieclip
- Create a duplicate instance of the sprite / movieclip original that's of type BitmapData class. You duplicate this using copyPixels method and making sure it's the same width + height.
- Create a 3rd instance of the original, this time with an alpha property applied to it, but it's visible property set to "none".
- On the duplicate (2nd) instance, you can include this 3rd instance as a source for the alpha properties in the copyPixels arguments
- Apply a ColorMatrixFilter to the 2nd instance to achieve your grayscale. It also accepts an alpha property if you don't want to use step 5 but your example looks like the alpha isn't the same everywhere, hence requiring the 3rd instance
I hope this helps. And if you're still not sure, just watch Primer.
精彩评论