Hello.
I have what I think should be an easy problem. I read through an array and count the occurrences of the values in it, I then write these to some variables, which I want to compare in a conditional. My conditional should trace which number occurs more.
Array code:
ActionScript Code:
private function runCount(scoreArray:Array, count1:Number, count2:Number, count3:Number):void {
for (var i:int=0; i < scoreArray.length; i++) {
if (scoreArray[i] == count1) {
_1count++;// = _1count + 1;
trace("1Count is:",_1count);
}
}
for (var o:int=0; o < scoreArray.length; o++) {
if (scoreArray[o] == count2) {
_2count++;// = _2count + 1;
trace("2Count is:",_2count);
}
}
for (var p:int=0; p < scoreArray.length; p++) {
if (scoreArray[p] == count3) {
_3count++;// = _3count + 1;
trace("3Count is:",_3count);
}
}
runFinal();
}
And conditional code:
ActionScript Code:
public function runFinal():void {
if (_1count > _2count || _3count) {
trace("more one than anything else");
} else if (_2count > _1count || _3count) {
trace("more two than anything else");
} else if (_3count > _1count || _2count) {
trace("more three than anything else");
}
}
Now, I get no errors, but my conditional gets very confused and spits out random results. Any ideas?
Thank you.
Update: As an example, this is what it gives me.
1Count is: 1
1Count is: 2
2Count is: 1
2Count is: 2
3Count is: 1
3Count is: 2
3Count is: 3
more one than anything else