





and adjust properties in the Properties Window. Make the rectangle 550x300










stop();
_root.ss.startBtn.onRelease = function() {
this._visible = 0;
_root.gotoAndPlay(2);
};








and adjust properties in the Properties Window






and paste in place (+SHIFT+V)
stop();
this.gotoAndPlay(10);

stop();


class PuzzlePiece extends MovieClip {
// static (class) properties set by script in the .fla
static var puzzleContent : String;
static var upClick : Sound;
static var downClick : Sound;
static var tol : Number;
static var pieces : Array;
// static (class) properties for internal use
private static var maxDepth : Number = 100;
// object properties
var templatePiece : MovieClip; // original piece on stage
var mask : MovieClip; // the mask for this clip
var maskPiece : MovieClip;
var holder : MovieClip;
private var _index : Number;
private var draggable : Boolean = false; // whether piece is draggable
public function PuzzlePiece() {
}
function init(templatePiece : MovieClip, index : Number) : Void {
_index = index;
// make a holder movie clip, and load content into it
holder = this.createEmptyMovieClip("holder", 1);
holder.loadMovie(puzzleContent);
//create a mask, and attach the puzzle piece to the mask
createEmptyMovieClip("mask", 2);
mask.attachMovie("piece" + index, "piece" + index, index);
maskPiece = mask["piece" + index]; // reference to the mask piece
maskPiece.number = index; // the piece knows its own number
setMask(mask);
// move the puzzle piece to its proper position
this.maskPiece._x = templatePiece._x;
this.maskPiece._y = templatePiece._y;
// remove the original piece
templatePiece.swapDepths(99);
templatePiece.removeMovieClip();
// add this piece to the array of pieces
pieces.push(this);
// update MaxDepth
maxDepth = Math.max(maxDepth, this.getDepth());
// assign functions to call on press and release
this.onPress = pressFunction;
this.onRelease = this.onReleaseOutside = releaseFunction;
}
public function toString() : String {
return ("puzzle piece " + _index);
}
private function pressFunction() {
if(!draggable) return;
this.swapDepths(++maxDepth); // bring piece above other pieces
downClick.start(); // emit click sound
this.startDrag(); // start dragging the piece
delete this.onEnterFrame; // cancel randomization
}
private function releaseFunction() {
if(!draggable) return;
upClick.start(); // emit a lower-pitched click
this.stopDrag(); // stop dragging
// check for connection to neighboring pieces
var otherPiece : MovieClip;
var maskPiece : MovieClip;
for(var j in pieces) {
otherPiece = pieces[j];
if(otherPiece == this) continue;
if( !this.mask.hitTest(otherPiece.mask) ) continue;
if( Math.abs(this._x - otherPiece._x) > tol || Math.abs(this._y - otherPiece._y) > tol ) continue;
for(var m in otherPiece.mask) {
maskPiece = otherPiece.mask[m];
var n = this.mask.attachMovie("piece" + maskPiece.number, "piece" + maskPiece.number, maskPiece.number);
n.number = maskPiece.number;
n._x = maskPiece._x;
n._y = maskPiece._y;
}
pieces.splice(parseInt(j), 1);
otherPiece.removeMovieClip();
}
_root.checkForCompletion();
}
}

stop();
puzzleContent = "puzzle.swf";
mainContent = "main_content.swf";
//how many puzzle pieces do you have
numPieces = ___;
// tolerance (in pixels) for placement of pieces
PuzzlePiece.tol = 16;
// set up sounds as class properties of PuzzlePiece class
PuzzlePiece.downClick = new Sound();
//the sound you want to play on mouseDown
PuzzlePiece.downClick.attachSound("_____");
PuzzlePiece.upClick = new Sound();
//the sound you want to play on mouseUp
PuzzlePiece.upClick.attachSound("_____");
/***************************************************************
Preload the puzzle image
***************************************************************/
p = _root.createEmptyMovieClip("picture", 1);
h = p.createEmptyMovieClip("holder", 1);
makePuzzle();
/* used for delaying randomization process
if you want to see the puzzle before
breaking it up in pieces use this code
select a number between 5 and 100 (5 is fastest)*/
//randomizeInt = setInterval(randomize, __);
/*otherwise use this line*/
//randomize();
loader = new MovieClipLoader();
loader.addListener(loadListener);
loader.loadClip(puzzleContent, h);
/***************************************************************
Cut the puzzle image into individual pieces
***************************************************************/
function makePuzzle() {
// initialize the class array "pieces," that holds references
//to all puzzle pieces
PuzzlePiece.pieces = new Array();
PuzzlePiece.puzzleContent = puzzleContent;
/* Because PuzzlePiece is a subclass of MovieClip, instances are
created by using attachMovie. Since this process passes no
parameters to the constructor, you need to call an initialization
function separately. */
//create a loop that loop for each number of pieces
//(use the variable from the top of the script)
for (i=0; i<___________; i++) {
piece = _root.attachMovie("PuzzlePieceSymbol", ["piece"+i], 100+i);
piece.init(_root["a"+i], i);
}
// Now that all the puzzle pieces are on the screen,
//you want to dim the original image
//select a number between 1 and 20 (1 being most transparent)
p._alpha = __;
/* The main content will be displayed after
the puzzle is completed. As this can be a large
file, you can load it while the puzzle is being solved*/
loadListener.onLoadComplete = null;
loadListener.onLoadProgress = null;
loader.loadClip(mainContent, h);
}
/***************************************************************
Check whether the puzzle is finished. This function is
called whenever a puzzle piece is released.
*************************************************************/
function checkForCompletion() {
// check if puzzle is done
if (PuzzlePiece.pieces.length>1) {
//not done
return;
}
// puzzle is done so stop the timer
clearInterval(timerInt);
// remove the completed puzzle, and show the post-completion content
PuzzlePiece.pieces[0].removeMovieClip();
//reset the alpha to 100%
p._alpha = ____;
//go to the second frame of your main_content
p.holder.gotoAndPlay(___);
}
/***************************************************************
Scatter the puzzle pieces.
***************************************************************/
function randomize() {
clearInterval(randomizeInt);
// start the timer
timerInt = setInterval(displayTime, 1000);
startTime = getTimer();
/* Each puzzle piece has its registration point at (0, 0), but
that isn't necessarily where its visible content is. You have to choose
a random position which keeps the visible content, determined by the
maskPiece, on the stage. */
for (i in PuzzlePiece.pieces) {
s = PuzzlePiece.pieces[i];
s.xr = Math.random()*(Stage.width-50)-s.maskPiece._x;
s.yr = Math.random()*(Stage.height-50)-s.maskPiece._y;
//every time the playhead enters the frame
//you want to call the function gotoDestination
//which will gradually move the pieces
s.onEnterFrame = goToDestination;
//you want the piece to be draggable
s.draggable = _____;
}
}
// Function to move gradually to a destination given by (this.xr, this.yr)
function goToDestination() {
this._x = this._x*.7+this.xr*.3;
this._y = this._y*.7+this.yr*.3;
if (Math.abs(this._x-this.xr)<2 && Math.abs(this._y-this.yr)<2) {
this._x = this.xr;
this._y = this.yr;
//once the pieces have arrived
//you delete this.xr,this.yr and this.onEnterFrame
delete this.xr;
delete ________;
delete this.onEnterFrame();
}
}
/******************************************
display a timer at runtime
*******************************************/
//movieClip.createTextField(instanceName, depth, x, y, width, height)
_root.createTextField("timer_txt", 8, ___, Stage.height-60, ___, ____);
timer_txt.autoSize = "left";
//format the text
fmt = new TextFormat();
//font size
fmt.size = ___;
//font
fmt.font="____";
//embed the font
fmt.embedFont=_____;
//set the text
timer_txt.setNewTextFormat(fmt);
function displayTime() {
s = Math.floor((getTimer()-startTime)/1000);
m = Math.floor(s/60);
s -= m*60;
ss = String(s);
if (ss.length<2) {
ss = "0"+ss;
}
timer_txt.text ="time taken= "+ m+":"+ss;
}