# Problem with Array

**URL:** <https://forum.kirupa.com/t/problem-with-array/295055>\
**Category:** flash\
**Created:** [August 24, 2009, 8:35pm UTC](https://forum.kirupa.com/t/problem-with-array/295055 "2009-08-24T20:35:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![foot01](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@foot01](https://forum.kirupa.com/u/foot01)\
**Post date:** [August 24, 2009, 8:35pm UTC](https://forum.kirupa.com/t/problem-with-array/295055/1 "2009-08-24T20:35:47Z")

</div>

Hey…I’m doing a simple array test…I thought I could have values in an array and then run it through a loop and have a IF this value equals “x” do whatever, ELSE do this.

I have the value on a button and it doesn’t work. The loop runs but the IF ELSE statement doesn’t do what I THOUGHT it should do. It runs every value through the script as if the IF ELSE statement doesn’t matter. Am I missing something?

Here’s the flash code (see below):

var myArr:Array = new Array;

myArr = [“red”, “green”,“blue”];

function checkArr (checkTest){

```
for(i= 0; i&lt;myArr.length;i++){
    if (checkTest == myArr*){
        trace("Value HIT" + myArr);
    } else {
    trace("NON Value HIT " + myArr);
}
}

```

}

red.onPress = function(){  
checkArr(“red”);  
}
