[CS 4] Checking if a certain string is in an array before another string

So I’m trying to code a system to combine different objects to create different effects (for a Flash Game). What I want to happen is if you hit the button for Element A, and there is an instance of ElementB in the array, the Elements “cancel out”, changing to a string called “Empty”. I can queue up elements, and find the first instance of an Element, but if Element B is in array[1] instead of array[0], Element A loads into array[0].
If traced it ends up being
“Element A, Element B, Empty, Empty, Empty”… and the goal is to have it have “Empty,Empty,Empty,Empty,Empty”
This is the “best” solution I’ve found, but it has the above problem. I know that the “else if” statement is why this is occuring, but I’m stumped on how to get around it.


SpellListener.onKeyDown = function() {
    if (Key.isDown(81)) {
        for (i in Spells) {
            if (Spells* == "Water") {
                Spells* = "Empty";
                break;
            } else if (Spells* == "Empty"){
                Spells* = "Lightning";
                break;
            }
        }

    }
    if (Key.isDown(65)) {
        for (i in Spells) {
            if (Spells* == "Lightning") {
                Spells* = "Empty";
                break;
            } else if (Spells* == "Empty"){
                Spells* = "Water";
                break;
            }
        }
    }

Basically I want it to check to see if string “Element A” is in the array, if not, check to see if “Empty” is in the array, if not, go to next space in array (note, the array is a 5 slot array, 0 - 4).
Any ideas?