# Load random sounds on enter frame

**URL:** <https://forum.kirupa.com/t/load-random-sounds-on-enter-frame/312542>\
**Category:** Uncategorized\
**Created:** [August 6, 2010, 12:39am UTC](https://forum.kirupa.com/t/load-random-sounds-on-enter-frame/312542 "2010-08-06T00:39:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![markyT](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@markyT](https://forum.kirupa.com/u/markyT)\
**Post date:** [August 6, 2010, 12:39am UTC](https://forum.kirupa.com/t/load-random-sounds-on-enter-frame/312542/1 "2010-08-06T00:39:46Z")

</div>

Hi everyone again. Now I know this should be straightforward to do, but seen as it’s early hours here, I need a fresh pair of eyes. Plus I’m a newbie so that doesn’t help!

At the launch of my movie, I want to load in a random sound clip from an array - here’s my code…

```php
import flash.media.Sound;

//create the array with linkage class names for sounds
var soundArray:Array = [sClip01, sClip02, sClip03, sClip04];

//randomise array
soundArray[Math.floor(Math.random() * soundArray.length)].addEventListener(event.ENTER_FRAME , playRandomSound);

		
var my_sound:Sound = new Sound();

my_sound.attachSound(soundArray);

function playRandomSound(): void {

    my_sound.play();
}

```

I’m pretty sure this isn’t working because on the ENTER\_FRAME command in the eventlistener, but could anyone show me the light on this? If there’s anything else wrong with this code, please feel free to pick it to bits.

As ever, thanks for the insight!
