Like I mentioned in my earlier post, I’ve been working on a large project that has a lot of AS2 mixed with densely layered FLAs, full of author-time elements.
I ran across an interesting nuance in masking, while trying to mask a run-time MovieClip, with a mask that was created in author-time.
Here it is:
Making an object in run-time and then calling its setMask and passing in an author-time movieClip will unmask whatever the author-time movieclip was previously masking.
There are a couple of ways around this problem:
1. Create an empty “holder” MovieClip, in author-time (you know, on the stage) and make sure it is being masked. Then, attach your run-time MovieClip to that holder instance. Problem solved.
2. You can also duplicate the mask using duplicateMovieClip and call setMask on your run-time MovieClip and pass in your new mask as the argument.
Still with me? Check out this example, it’s way less confusing.
Neither approach is terribly elegant, but if you’re mixing author-time and run-time elements, there’s bound to be some non-elegant-ness anyway.
You might be thinking, “Hey, I’m a coder. Why would I bother with an author-time mask, anyway? I’d rather make one in code and then use it how I please.” I hear ya.
When I was presented with this problem, I had a mask, created in the Flash IDE that was masking dozens of layers, with a complex animation and functioning perfectly. All it needed was one or two run-time elements to be behind the mask. At that point, it’s not worth the trouble to recreate the mask, with its crazy animation, in code, just to pull one or two things under it.
When developing in Flash, especially when designers and developers of varying skill levels are contributing code, these situations will come up. Sometimes, you just gotta hack.