
Код:
onClipEvent(mouseDown) {
// get mouse location
mx = _root._xmouse;
my = _root._ymouse;
// loop through pieces looking for hit
for(x=0;x<3;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 = 3;
y = 4;
break;
}
}
}
}
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;
}
}
Данный код был мной нагло украден

Я не особо во всем разобрался, т.к. знание Actionscript еще неделю назад было вобще нулевое, но я так понимаю, что фишка в этой строчке

Код:
piece = _root[x+"-"+y];
и если элементы мозайки будут называться не 0-0 0-1 1-0 2-0 итд, мой piece двигаться не будет
