Home > Flash > Masks: The Pros, The Cons and Other interesting info.

Masks: The Pros, The Cons and Other interesting info.

Masks are great! We use them all the time for everything. Masking is a way of life for some designers (myself included).

But masks can be serious runtime performance killers. How? Why?

Well, without getting into way too much detail, timeline masks aren’t actually keeping your animations and artwork contained within their bounds. They’re just making everything outside at 0% alpha. Flash still has to re-draw that 0%-edness.

This can seriously hurt performance, especially with complex animations/artwork.

Speaking with Andreas Heim, and working with Greg Schlimm on a small project, we discovered a couple helpful tips to keep performance dives to a minimum.

First, if at all possible, try not to turn layers to masks. There’s absolutely no way of getting performance back.

In order to have a mask and not have it set on the timeline and not hurt at runtime, do these quick/easy steps:

1. After creating your vector mask and your animation/artwork where you like it, give both a unique instance name. (Here I will call them maskee for the artwork, and masker for the actual mask.)

2. Check “Use runtime bitmap caching” on the properties of maskee only.

3. Create an AS layer – if there isn’t one already.

4. On the first frame where the artwork/mask appear, on the AS layer, type this:

maskee.mask = masker;

This will keep the animation only within the bounds of the mask. No drawing anything outside at 0% alpha.

**Note** if you animate the mask itself, Flash still doesn’t redraw maskee outside of the bounds but does have to redraw masker. **End Note**

Also note that this works solely with vector masks. To use a bitmap or gradient mask, you MUST check “Use runtime bitmap caching” on both mcs. But you lose the performance enhancement.

Advertisement
Categories: Flash Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.