PDA

View Full Version : jigsaw puzzle once complete


johnsonn
04-18-2005, 12:30 PM
I have been playing with a jigsaw puzzle example from :

"Macromedia Flash 5 ActionScript Fun and Games
View Larger Image Gary Rosenzweig
Que, Paperback, Published April 2001, 415 pages, ISBN 078972524X"


Here is the script, is there a way I can determine that once the puzzle is complete I could gotoAndPlay(x).




onClipEvent(mouseDown) {
// get mouse location
mx = _root._xmouse;
my = _root._ymouse;

// loop through pieces looking for hit
for(x=0;x<6;x++) {
for(y=0;y<4;y++) {
piece = _root[x+"-"+y];

// see whether the piece is under the cursor
// and if it has not yet been placed
if (piece.hitTest(mx,my) and (piece._alpha < 100)) {
// this is the piece clicked
piece.startDrag();

// break out of all loops
x = 6;
y = 4;

gotoAndPlay(10);
;
}
}
}
}

onClipEvent(mouseUp) {
// stop piece from moving
stopDrag();

// get distance from center of piece
// to center of outline

dx = _root.outline._x - piece._x;
dy = _root.outline._y - piece._y;
dist = Math.sqrt(dx*dx+dy*dy);

// if close enough, then set it in place
if (dist < 10 ) {
piece._x = _root.outline._x;
piece._y = _root.outline._y;

// set to full color
piece._alpha = 100;
}
}



thanks,tyjn