# Sound loop pauses with actionscript

**URL:** <https://forum.kirupa.com/t/sound-loop-pauses-with-actionscript/105840>\
**Category:** Uncategorized\
**Created:** [March 30, 2004, 8:02am UTC](https://forum.kirupa.com/t/sound-loop-pauses-with-actionscript/105840 "2004-03-30T08:02:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_Brown](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@J\_Brown](https://forum.kirupa.com/u/J_Brown)\
**Post date:** [March 30, 2004, 8:02am UTC](https://forum.kirupa.com/t/sound-loop-pauses-with-actionscript/105840/1 "2004-03-30T08:02:41Z")

</div>

I am having a basic problem with some scripting that I am doing. Basically, I have a script that allows for random files to be played sequentially, but the problem is that when it pulls up the second file to play there is a slight pause. Now I have read the tutorials etc, and have the sounds as wav files and set to event rather than stream and I have checked the wav files and they are fine. I even set one of these loops with the pause to play itself over and over again and had no problems. It seems as though the problem arises when the script has to do some math (i.e. random loop picking from an array)

Any help would be greatly appreciated.

Thanks for your time  
James

below is the code  
[AS]  
songNumber == undefined  
subNumber == undefined  
subNumber = random(8);  
songNumber = random(5);  
subSound = new Sound (this);  
arrayNumber = songNumber;  
songName = new Array (“base”,“guitar fade”,“chill birds”,“wurlitzer fade”,“just music”);  
if (songNumber == 0) {  
EgSound = new Sound(this);  
EgSound.attachSound(songName[songNumber]);  
EgSound.start(0, 1);

}  
if (songNumber == 1) {  
EgSound = new Sound(this);  
EgSound.attachSound(songName[songNumber]);  
subarraySong = new Array (“base”,“guitar shred”);

```
    if (subNumber &lt;= 6) {
            playSub = subarraySong[0];
    } else if (subNumber &gt; 6) {
            playSub = subarraySong[1];
    }
    subSound.attachSound (playSub);
    EgSound.onSoundComplete = function() {
            
            subSound.start (0,1);
    }
    EgSound.start(0, 1);

```

}

if (songNumber == 2) {  
EgSound = new Sound(this);  
EgSound.attachSound(songName[songNumber]);

```
    subarraySong = new Array ("chill birds and tuba","full orchestra chill","base");
    
    if (subNumber &lt;= 2) {
            playSub = subarraySong[0];
    } else if (subNumber &gt; 2 &lt;= 5) {
            playSub = subarraySong[1];
    } else if (subNumber &gt; 5) {
            playSub = subarraySong[2];
    }
    subSound.attachSound (playSub);
    EgSound.onSoundComplete = function() {
            
            subSound.start (0,1);
    }
    EgSound.start(0, 1);

```

}

if (songNumber == 3) {  
EgSound = new Sound(this);  
EgSound.attachSound(songName[songNumber]);  
EgSound.onSoundComplete = function() {

```
            subSound.start (0,2);
    }
    EgSound.start(0, 1);

```

}  
if (songNumber == 4) {  
EgSound = new Sound(this);  
EgSound.attachSound(songName[songNumber]);  
EgSound.onSoundComplete = function() {

```
            subSound.start (0,2);
    }
    EgSound.start(0, 1);

```

}

[/AS]
