[F8] URGENT! Looping through array

SHORT EXPLANATION:
I have 5 cards on the stage (named plocica0 to plocica4) and dynamic text (named pojam) in each.
In code, I have 3 different arrays (named niz1, niz2, niz3) populated with sentences. I’ve created a function which have to populate these cards with sentences from given arrays but without repeating them - meaning each card should have different sentence inside.

I need next procedure (if possible):

  • choose five sentences (one by one) from given arrays (without changing them)
  • push them into new array
  • then, if possible, while populating new array with sentences, compare them - in my function I’ve tried to create a procedure of comparsion in a way of pushing the last chosen sentence into array and then, with a counter, loop through previous sentences in that array and if found two same sentences, delete last one and repeate the procedure of choosing as long as they are the same
  • the whole procedure of choosing sentences should last as long as all five of them aren’t different

My code:

var niz1 = Array("Volim te.","Ljubavi moja.","Ti si zečić.","Danas je lijepi dan.");
var niz2 = Array("Jučer je bilo lijepo.","Sutra je ponedjeljak.","Ti znaš plivati?","Danas radim.");
var niz3 = Array("Dusche dich am Vormittag nicht!","Zeko piše.","Mario fotografira.","Mačke spavaju.");

function chooseSentences() {
    var chosenSentences = new Array();//container for chosen sentences
    var chosenIndex = new Array();
    var chosenArrElement:Object = new Object();
        
    for (var i = 0; i < 5; i++) {
        var chooseArr = random(3) + 1;
        var chooseElement = random(4);
        chosenSentences* = this["niz" + chooseArr][chooseElement];
        trace("chosenSentences original: "+chosenSentences*);
        
            var j = 0;
            while (j < i) {
                if (chosenSentences* == chosenSentences[j]) {
                    do {
                    var popped:Object = chosenSentences.pop();
                    trace("popped: "+popped);
                    chooseArr = random(3) + 1;
                    chooseElement = random(4);
                    chosenSentences* = this["niz" + chooseArr][chooseElement];
                    trace("chosenSentences new choice: "+chosenSentences*);
                    }
                    while (chosenSentences* == chosenSentences[j]); 
                }
                else {
                    j++;
                }
            } //end while (j<i)
        

        chosenArrElement.array = chooseArr;
        chosenArrElement.element = chooseElement;
        chosenIndex* = [chosenArrElement.array,chosenArrElement.element];
    }
    trace("final: "+chosenSentences);
    trace("chosenIndex: "+chosenIndex);    

    //writting into cards:
    for (var k = 0; k < chosenSentences.length; k++) {
        _root["plocica" + k].pojam = chosenSentences[k];
    } 

} // End of function
stop();

onLoad = function() {
    chooseSentences();
}