Array Conditional problem
Hello once again I have seen to run into another issue which I hope the Flash Guru's will be able to answer.
I have a function that checks two arrays and returns a boolean value based on if they match or not, from here I have a conditional that handles the boolean values. My problem is if a solution isn't in the first positon of my array the conditional will go through and hit the else statement first until it does find the right solution, by that time it treats it as a non match. I need to find a way for it to go through the array first, find if something is found, then hit the conditionals, not really sure how I can do that, any help or ideas would greatly be appreciated, thanks.
//my check array function
//both functions uses a match array(pushes user's two selections), and a solutions array(a multidimentional array that contains pairs i.e[1,2],[3,4]).
//if the match array length reaches 2 then checkForSolution is called.
function checkIfArraysMatch(arrayA:Array, arrayB:Array):Boolean
{
var isMatch:Boolean = true;
if (arrayA.length == arrayB.length)
{
for (var i:int = 0; i<arrayA.length; i++)
{
if (arrayA != arrayB)
{
isMatch = false;
break;
}
}
}
else
{
isMatch = false;
}
return isMatch;
}
//my conditional function
function checkForSolution(e:TimerEvent)
{
for (var i:int = 0; i<solutions.length; i++)
{
if (checkIfArraysMatch(match,solutions) || checkIfArraysMatch(match.reverse(),solutions))
{
solutions.splice(i,1);
//fires function to handle a correct response
}
else
{
objectsArr[0].imgHolder.visible = false;
objectsArr[1].imgHolder.visible = false;
objectsArr[0].gotoAndStop(1);
objectsArr[1].gotoAndStop(1);
}
match.splice(0);
objectsArr.splice(0);
for (var ii:int=0; ii<cardArray.length; ii++)
{
cardArray[ii].addEventListener(MouseEvent.CLICK,moEvent);
}
if (! solutions.length)
{
trace("end of game");
}
}
