Please look at the following code:
// this tells the flash their are 6 pieces and to randomize them around using
// the math random function, it also scales them down smaller than their originals
n=parseInt("6");
success = 0;
for(i=1;i<=n;i++) {
this["p"+i]._y = Math.random()*150;
this["p"+i]._x = Math.random()*150;
this["p"+i]._xscale = 50;
this["p"+i]._yscale = 50;
}
// allows the piece to moved about using hittest and startdrag functions
on(press) {
if(this.hitTest(_root._xmouse,_root._ymouse))
{
this.startDrag();
}
}
// after the user has stopped dragging
on(release) {
stopDrag();
name = this._name;
int_name = name.substring(1);
int_name = parseInt(int_name);
// compares the intended position with position of the placeholder
// if correct it will replace it with piece from the preview movieclip
// using attachsound function will play a click to give user feedback
if(eval(this._droptarget) == _parent["placeholder"+int_name] )
{
_parent.preview["p"+ int_name]._visible = true;
this._visible = false;
snd = new Sound();
snd.attachSound("snd_click");
snd.start();
// if all pieces are in their correct positions it will make the puzzle movieclip invisable
// and replace it with the welldone movie clip
_parent.success++;
if (_parent.success == _parent.n)
{
_root.puzzle._visible = false;
_root.welldone._visible = true;
_root.welldone.play();
}
}
// if the position the user chooses is incorrect, the piece will snap back
// but randoimize its new position using the math.random function
// it will also play the error sound from the library to give the user feedback
else
{
this._y = Math.random()*150;
this._x = Math.random()*150;
snd = new Sound();
snd.attachSound("snd_error");
snd.start();
}
}
Im wanting to basically do what you see here but in a different way! Do you have any ideas for ways of doing the above code but using different code if you get me.