Maybe you can adapt this...
Code:// bottom layer - 'linesMC', empty movie clip at 0,0 // middle layer - dot movie clips, put instance names in dots array below // top layer - 'drawMC', empty move clip at 0,0 var lineColor = 0x000000; var dots = [dot1, dot2, dot3, dot4, dot5, dot6, dot7, dot8]; var startDot = null; onMouseDown = updateLines; function updateLines() { var dot = checkHit(dots); if (dot != null) { if (startDot == null) { startDot = dot; onMouseUp = function () { checkLine(); startDot.onEnterFrame = null; startDot = null; }; startDot.onEnterFrame = function() { drawMC.clear(); drawMC.lineStyle(6,lineColor,80); drawMC.moveTo(this._x,this._y); drawMC.lineTo(_xmouse,_ymouse); }; } else { checkLine(); startDot.onEnterFrame = null; startDot = null; } } else { var line = checkHit(linesMC); if (line != null) { removeMovieClip(line); checkComplete() } } }; function checkLine() { var dot = checkHit(dots); if (dot != null && startDot != dot) { var mc = linesMC.createEmptyMovieClip("mc" + linesMC.getNextHighestDepth(), linesMC.getNextHighestDepth()); mc.lineStyle(6,lineColor,100); mc.moveTo(startDot._x,startDot._y); mc.lineTo(dot._x,dot._y); checkComplete(); } drawMC.clear(); } function checkHit(grp) { var mc = null; for (var i in grp) { if (grp[i].hitTest(_xmouse, _ymouse, true)) { mc = grp[i]; return mc; } } return mc; } function checkComplete() { var ct = 0; var len = dots.length - 1; var num = 0; for (var i in linesMC) { for (var j = 0; j < len; j++) { if (linesMC[i].hitTest(dots[j]._x, dots[j]._y, true) && linesMC[i].hitTest(dots[j + 1]._x, dots[j + 1]._y, true)) { ct++; } } num++ } if (num == ct && ct == len){ trace("puzzle complete") onMouseDown = null; } }




Reply With Quote