Array Troubles

Hi all,

I’ll start by posting my code then explain what I want it to achieve.

var    chosenIngredient        :String;
var maxPreviewIngredients    :Number;
var previewIngredients        :Array    = [];
var ingredientsList            :Array     = ["carrot","onion","tomatoe","mushroom","steak","celery"];

chosenIngredient        =    ingredientsList[random(ingredientsList.length)];
maxPreviewIngredients    =    3;
previewIngredients.push(chosenIngredient);

function onEnterFrame(){
    trace(previewIngredients);
    ingredeintHud();
}

function ingredeintHud(){
    for(ingredientCheck=0; ingredientCheck < previewIngredients.length; ingredientCheck++){
        if(previewIngredients.length<maxPreviewIngredients){
            if(previewIngredients[ingredientCheck] == chosenIngredient){
                chosenIngredient        =    ingredientsList[random(ingredientsList.length)];
            }else{
                previewIngredients.push(chosenIngredient);
            }
        }
    }
}

What I am attempting and failing to do after much trial and error is to have a random ingredient from the ingredientList array pushed into the previewIngredients array making sure the new value going in is not already in the preview ingredients array. If the same value is there I want it to keep choosing an ingredient from the list array until it finds a value thats not in the preview array then push that one in there.

It feels like I’m getting close but obviously I’m either going about it the wrong way or just missing a little somthing somthing out.

Any ideas?

Thanks in advance.