Modifying the A L I C E picture puzzle game code.
STUDY THE CHANGES MADE ON MONDAY and TUESDAY:
Here are the Frame #2 code improvements:
// Assign names done NOW using a FOR loop to each element in the myClip array. // VIP: Also recording the clipNumber 0, 1, 2, 3, 4, 5, 6 or 7 with each object. ---------- for (var p:int = 0; p < numClips; p++) { myClip[p].name = "piece" + p; myClip[p].clipNumber = p; } ... // Generate random location (x and y positions) for the 8 movie clip puzzle pieces. for (var i:int = 0; i <= 7; i++) { myClip[i].x = Math.random() * 225 + 320; myClip[i].y = Math.random() * 310; }
//function pieceMove triggers the startDrag and stopDrag methods on mouseDown and mousep function pieceMove(evt:Event):void { if (evt.type == "mouseDown") { evt.target.startDrag(); } else if (evt.type == "mouseUp") { evt.target.stopDrag(); var theClipNumber:int = evt.target.clipNumber; if ( evt.target.hitTestObject( nph[theClipNumber] ) ) { trace("Target clipNumber " + evt.target.clipNumber); removeChild( myClip[theClipNumber] ); nph[theClipNumber].alpha = 0; //set alpha of the little rectangle to 0 tpg[theClipNumber].alpha = 100; //set alpha of the old puzzle piece to 100 score++; } else { evt.target.x = Math.random() * 215 + 320; evt.target.y = Math.random() * 310; } } scor.text = score.toString(); if (score == 8) { msgbox_txt.text = "Way to go, " + theName + "!"; timer.stop(); gotoAndStop(3); } }
********************************************* STUDY CHAPTER SIX *********************************************