Link to home
Start Free TrialLog in
Avatar of courtthree
courtthree

asked on

Flash AS3 CacheAsBitmap problem when masking

Hi all,

This one has really got me - if there is an answer then it's definitely worth more than 500 points!

I have two movieclips, both dynamically generated. One is to be used as a mask for the other. The clip to be masked is rectangular in shape and the clip doing the masking is a parallelogram. The mask is dynamically resized so has 9-slice scaling enabled to ensure its angled edges remain intact. Nothing out of the ordinary so far.

The first problem that had to be overcome was that a movieclip distorts and ignores the 9-slice-scaling when its used as a mask. I used the CacheAsBitmap and nesting trick I found here to fix this problem: http://www.kirupa.com/forum/showthread.php?t=334533

So, everything looks perfect at this point.

Now, here's the hard part. The hit area of the masked clip is behaving like it has been masked by the distorted mask, not the beautifully 9-slice-scaled mask! SO, to recap, the movieclip displays exactly as planned on the stage once masked, but its invisible hit area behaves as though it has been masked by a non-9-slice-scaled, distorted version of the masking clip!

I have been staring at my screen for 4 straight hours - PLEASE HELP!
Avatar of deepanjandas
deepanjandas
Flag of India image

I would like to see the scenario, can you share your snippet. It will be easier to suggest.

Warm Regards
Deepanjan Das
Avatar of courtthree
courtthree

ASKER

I don't know if this will help much but the function that applies the mask (it's reusable by several clips) is pasted below. "inner" is the 9-sliced mc inside the masking clip that gets resized...
private function angleMask(mcClipParent:MovieClip, mcClipToMask:MovieClip, nX:Number, nY:Number, nW:Number, nH:Number, maskType:Class) {
			var newMask:MovieClip = new maskType();
			mcClipParent.addChild(newMask);
			newMask.x = nX;
			newMask.y = nY;
			newMask.inner.width = nW - 200;
			newMask.inner.height = nH;
			newMask.cacheAsBitmap = true;
			mcClipToMask.cacheAsBitmap = true;
			mcClipToMask.mask = newMask;
		}

Open in new window

Adendum: The "void" is missing on the above. It exists in my actual code.
ASKER CERTIFIED SOLUTION
Avatar of James Tomasino
James Tomasino
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.