I thought it was very easy to use the mask In Flex. Naturally, I wrote the following:Code:
< MX: Image Source = "Assets/bg.jpg" Mask = "{Maskimage }" />
< MX: Image Source = "Assets/wjx.png" ID = "Maskimage" />
Result: failed. The background image shows the size of the mask layer, but the transparent mask effect is not met.
Then, we learned from Google that the cacheasbitmap of the mask layer must be set to true when this transparent mask is used; otherwise, it is invalid.
< MX: Image Source = "Assets/bg.jpg" Mask = "{Maskimage }" />
< MX: Image Source = "Assets/wjx.png" ID = "Maskimage" Cacheasbitmap = "True" />
Result: failed. Same effect
Search for results from Google, find an example, and modify the code as follows.
< MX: Image Source = "Assets/bg.jpg" Mask = "{Maskimage }" >
< MX: Filters >
< MX: dropshadowfilter />
</ MX: Filters >
</ MX: Image >
< MX: Image Source = "Assets/wjx.png" ID = "Maskimage" Cacheasbitmap = "True" />
Result: success.
Although the effect has been achieved, there is still a question about how to apply a filter to the background image to implement a transparent mask.
Hope that experts can answer the question.
The following describes when cacheasbitmap will be used. Thank you for sharing your experience:
Content from: http://as3blog.com/as3/when-and-how-to-use-cacheasbitmap/
Based on official instructions and my own experience, share the following information:
when cacheasbitmap is used:
1. A large number of animations exist on a complex vectoring background image.
2. scroll text area;
3. window-based applications (you often drag the entire area)
4. transparent mask (mandatory, otherwise invalid)
when cacheasbitmap is not used:
1. do not abuse it. cacheasbitamp consumes a lot of memory. A 250 × 250 pixel rectangle may occupy KB of memory after being cached!
2. Do not use the target element when it is scaled.
3. The target element itself should be static, or do not flip or zoom an animation frequently.
4. Do not mix the vector image with the cached bitmap.