PDA

View Full Version : hitTest and drag on a masked layer object


madness
10-29-2001, 06:27 PM
I am making a jigsaw puzzle which consists of many movie clips that have the same photo masked out of different puzzle piece shapes.

I can get the pieces to drag around and drop into the correct space just fine, but my mouse doesn't move around the piece directly under it. Rather it seems to grab the entire area of the (hidden) masked photo (meaning it usually picks up which ever piece is closest to the top vs. just the puzzle piece shape).

Is it possible to use the hitTest command on a masked layer in a mc so that it only returns the value "true" if on the masked layer and not the entire image hidden behind it?

Or is there someway for me to create coordinates on each individual mc so that the mouse drags the one under it versus whichever piece is on top?

If this is all too confusing I can post my example. Thanks!

madness
10-30-2001, 03:20 PM
I've posted the swf file at:
http://members.tripod.com/mclarke8/shaverGame.html

Unfortunately the fla is too large for me to upload there, but the main question is: how to target the piece that shows through the mask versus the entire masked photo?

Add another movie clip on top, combine those and target it instead? If anyone can think of something else to try it would be most appreciated.

poab
10-30-2001, 04:05 PM
Hi,

Each piece should be in a MC of it's own. Make a button that's the same size and shape as your mask by copying and pasting onto a new layer. Now you have a button under the mask and masked layers add this code to it:

on(press){
startDrag(PATH TO MC GOES HERE, false); //change 'false' to 'true' if you want the MC centered on the mouse
}
on(release){
stopDrag();
}

It might be an idea to alter the levels of the MCs too. So when someone clicks one that's the bottom of the pile it rises to the top.

cheers.

madness
10-30-2001, 06:12 PM
Thanks poab,

Each piece is its own mc right now, but I'll try the button idea to see if it restricts the hit area. Your changing levels idea is a good one, I'll give that a shot too.

geak
10-30-2001, 06:35 PM
Also a little unknown hint. The bounds of the MC is not defined by the mask but by the entire contents of the MC. So you either need to use an invisible button as poab suggested or if you break your image in each MC ie Ctrl or comman -B you can then use the white mouse pointer, the one that you use for modifying bezier curve handles with, and you can grab the corner node of the picture and shrink it to the bounds of the mask. This sounds a little confusing I know but it works.