onSoundComplete & for loops combinations ! is this so easy that its impossible?

Hi all,

Here I am once again with a very strange problem that seems so easy to accomplish but has had me flummoxed for more than 2 days now. So i turn once again to my redeemer, the Kirupa forum and all its gurus as well as amateurs.

So a small piece of code is giving me nightmares. Basically this piece of code plays 6 sounds in the Array grpArr which are passed to to function goi(). This it accomplishes perfectly. Then I tried to use the a for loop with the goi function in it. ( I have commented out that code) I wanted to send sounds from the array to goi in small groups of 2 or 3 sounds sent 3 or 2 times respectively. The logic seems OK but the output is unfathomable.

So i want to do as follows: - send sounds [a,b] from grpArr, in the first loop to goi(), then sounds [c,d] via 2nd loop and finally [e,f] in the 3rd loop to goi(). After each loop, i want a pause of 5 seconds ( this i did not reach and so its not implemented).

All efforts to achieve this simple bit of logic have gone in vain. can someone please help and tell me whats wrong here and how this logic can be implemented?

The code is as below:-

var grpArr:Array = ["a","b","c","d","e","f"]; // sound Array
var part=0;                 
// var sndBlk = 3;




    moi(grpArr);


/*
for (jj=0; jj<2; jj++)
    {
        moi(grpArr);
    }
*/    
    
function moi(inputArr:Array) {
    s = new Sound();
    s.attachSound(inputArr[part]);
    s.start();
    s.onSoundComplete = function ()
    {
        if (part < inputArr.length-1)
        {
            part++;
//            trace("inputArr["+ part+"]= "+ inputArr[part]);
            s.attachSound(inputArr[part]);
            s.start();
        }
    }
}

Thanks all for their time , effort and help,
Ajoo.