Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Flash AS3 CacheAsBitmap problem when masking

Posted on 2011-03-19
7
Medium Priority
?
1,184 Views
Last Modified: 2012-05-11
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!
0
Comment
Question by:courtthree
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35173922
I would like to see the scenario, can you share your snippet. It will be easier to suggest.

Warm Regards
Deepanjan Das
0
 
LVL 6

Author Comment

by:courtthree
ID: 35174710
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

0
 
LVL 6

Author Comment

by:courtthree
ID: 35174716
Adendum: The "void" is missing on the above. It exists in my actual code.
0
 
LVL 3

Accepted Solution

by:
James Tomasino earned 2000 total points
ID: 35233073
I'd suggest using a non-standard hittest. I've run into a handful of problems with advanced masks in Flash, like the 20x scaling of duplicated bitmap masks, and this very one. Luckily, plenty of folks have made great hittest functionality that you can use to get around the built-in Flash methods. I'd recommend Grant Skinner's pixel perfect hit test. There's a few versions out there, but the latest I remember seeing was updated by Troy Gilbert (http://troygilbert.com/2009/08/pixel-perfect-collision-detection-revisited/). This will take a little work to implement if you want to use the class natively, as it assumes hit tests between two objects, not an object and the mouse. You could, I suppose, create an invisible pixel-sized object that gets assigned to the mouse x & y upon a click before running the test. It's a bit of a hack, but hopefully this method will work better for you. Good luck.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 36978229
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question