I am in the process of making a jigsaw game. For testing purposes, it is only a 4 piece, square puzzle. I have 4 seperate movie clips named one, two, three, and four.
I wanted to make it different than the other jigsaw puzzles I’ve seen in flash, and wanted to make it so that when you ‘connect’ pieces that go next to each other, they actually follow each other.
In each movie clip I have :
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.startDrag();
}
}
onClipEvent (mouseUp) {
this.stopDrag();
}
There is only one frame, and on the first frame’s actions I have :
stop ();
_root.one.onEnterFrame = function () {
if (_root.one.hitTest(_root.two)) {
xposition1 = getProperty("/one", _x);
yposition1 = getProperty("/one", _y);
setProperty(/two, _x, _root.one._x + 205);
setProperty(/two, _y, yposition1);
}
}
That code all works just fine ( I know I can clean it up a little, but I am not concered with neatness just yet. Once it is done I will clean up the code). What I am trying to do though is make it so that I can create an array and have it loop for the function of each movie clip. I have this code, yet don’t know exactly how to implement it:
myArray = ["one", "two", "three", "four"];
for (j=0; j < myArray.length; j++) {
blah += myArray[j];
What I want is when a MC checks for a hitTest, I want a function for it to test which other MC it hit, rather than listing them each individually like in the first code snippet I showed. I don’t want to code for each instance, though I will, I just wondered if there’s a way to to do it with Arrays.
I am attaching a copy of the fla i’ve been workin on. Thanks so much. Heck, if theres a better way to do it too, let me know!