View Full Version : Advanced Masking Question

08-25-2007, 06:33 PM
Hey everybody.

I'm currently working a project where you can do the tired old "dress up a virtual character" in Flash. Of course everything else was easy about it, drag and drop clothing articles on the character, etc. However, this particular project had a bit of a twist. The end-user will be allowed to upload their photo, and then super-impose their head onto the top of the character they are dressing up.

Originally I figured we'd just use a pre-sized oval mask, and have the user resize the photo into the oval mask so that their head fits in it. But the client is inquiring as to whether it would be possible to allow the user to perhaps draw an outline around the portion of the photo they want to extract, and then have Flash mask it that way.

Do any of you know if this is possible? I presume it's going to be a mixture of the drawing API and various other actionscript voodoo, but since I'll be dealing with basically dynamically masking a dynamically-loaded image, I figured I'd do some research on the feasability of this before wasting time, since I have one week left to completion.

03-31-2008, 05:18 PM
I am looking to do the same thing.. did you ever find a solution to this?

03-31-2008, 05:23 PM
Nope, never did. The budget just didn't allow for me to research it anymore, so we went with three pre-sized oval masks that the user can choose from. I added a shadow to the mask MC's to give it some depth and it worked out okay.

You can actually view it at http://www.rasmussenrocks.com/ and go to the MyRocker area of the site. That is the app.

03-31-2008, 05:58 PM
Using AS you could certainly do this. When the user draws the oval or whatever, then you could make it into a movie clip, and set the picture's mask to the new movie clip. :D

I'm not sure how you would code it exactly, but I don't have Flash on this computer. I think it would be something like: myPicture.mask = drawnShape Might not be as simple in AS2 (or 1) but I think that property exists.

Feel free to prove me wrong though...

03-31-2008, 07:43 PM
I got it to work. I basically did what Durnus said, with some variations. I wanted it to look more like the crop tool in photoshop, where it darkens the rest of the picture slightly, so i created a shape and then as the user draws, it removes part of the shape. All the while i'm putting the points into an array, and then when they want to crop the image it recreates that shape(the empty area) and sets that shape as a mask

06-25-2008, 09:45 AM
Hey guys
when image is saved/uploaded on server, do you load it up again in swf,

1-after you mask it, is that image saved again as jpeg? or what happens here, do you just save the coordinates/preferences in xml?