I am creating a simple Jigsaw puzzle in part of a navigation system for a trivia page. previously in action script 2.0 you could use the eval method. I have changed the most part of my code to be compatible with 3.0 by changing my eval classes to **this[“myMovieClip”+ i]
However I am uncertain what to do for part of my IF statement, **I am relativley new to using flash and I am stuck here is the code so far (Note the part I am stuck on is in bold text) thanks for any help
var noOfPieces:Number = 24;
var selectedDepth:Number = 50;
//Loop to assign.
for(var i = 1; i <= noOfPieces; i++) {
//Randomly places the pieces.
this["myMovieClip" + i + "_mc"]._x = Math.ceil(Math.random()*600) + 100;
this["myMovieClip" + i + "_mc"]._y = Math.ceil(Math.random()*400) + 100;
//assign a depth to each piece.
this["myMovieClip" + i + "_mc"].swapDepths(i);
//assign an ID to each piece.
this["myMovieClip" + i + "_mc"]._id = i;
//assign variable to check wether solution is solved or not.
this["myMovieClip" + i + "_mc"]._solved = false;
//drag when pressed.
this["myMovieClip" + i + "_mc"].onPress = function (){
this.swapDepths(selectedDepth);
this.startDrag();
};
//stop the drag when released.
this["myMovieClip" + i + "_mc"].onRelease = function(){
this.stopDrag();
//check to see whether the puzzle is in place.
[SIZE=4] ** if(this.hitTestObject(eval("p" + this._id + "h_mc")._x, eval("p"+ this._id + "h_mc")._y, true)){**[/SIZE]
//auto align
this._x = this["myMovieClip" + this._id + "h_mc"]._x;
this._y = this["myMovieClip" + this._id + "h_mc"]._y;
//puzzle is in right place.
this._solved = true;
//push the depth to lower levels
this.swapDepths(- this._id);
//check whether all have been solved
checkSolution_fn();
//disable event handlers
delete this.onPress;
delete this.onRelease;
}else{
//not solving
this._solved = false;
}
};
}