Line 1 - A variable to hold the total number of differences in each level. An Array could be used for varying difference total in each level.
Line 2 - The total of differences found is stored so that something can be done if all of them are found.
Line 3 - A function to make the differences which will be called in both versions. thisSide refers to the side which the user finds a difference in. otherSide refers to the side which will respond.
Line 4 - A for loop is used to loop through each difference (dif1, dif2, dif3). The numbers of times to loop is determined by "differences", which currently is 3.
Line 5 - Each difference can be refered to in the loop by using thisSide["dif"+i], but a temporary variable is used to shorten it.
Line 6 - each difference's hand cursor is turned to false so that the hand is not shown when the user moves the mouse pointer over it.
Line 7 - the difference has not been found yet, but when it is it will be set to true, so that it cannot be pressed again.
Line 8 - a poperty is created to store the opposite difference which will respond when the current one is pressed.
Line 9 - To prevent the user from cheating by using the Tab key, tabEnabled is turned to false.
Line 10 - The difference movieclip is assigned a function for when it's pressed. The rest of the code will be executed when the difference is pressed.
Line 11 - If the difference hasn't been found
Line 12 - Play the difference movieclip. Playing it will make it flash, as we set it up earlier to do so.
Line 13 - The other side's difference will also play
Line 14 - The difference has now been found, so we don't want it to be clickable any longer.
Line 15 - Set the other difference movieclip's found property to true also
Line 16 - Increase the found variable by 1
Line 17 - Check if all the differnces are found. This is for expanding on this tutorial by adding move levels in the "levels" movieclip
Line 18 - Set found to 0 for the next level
Line 19 - play the levels movieclip (for when you add more levels) |