# I have a random sentence generator, but how do I add sound to it?

**URL:** <https://forum.kirupa.com/t/i-have-a-random-sentence-generator-but-how-do-i-add-sound-to-it/237281>\
**Category:** flash\
**Created:** [August 28, 2007, 10:03pm UTC](https://forum.kirupa.com/t/i-have-a-random-sentence-generator-but-how-do-i-add-sound-to-it/237281 "2007-08-28T22:03:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tivaelydoc](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@tivaelydoc](https://forum.kirupa.com/u/tivaelydoc)\
**Post date:** [August 28, 2007, 10:03pm UTC](https://forum.kirupa.com/t/i-have-a-random-sentence-generator-but-how-do-i-add-sound-to-it/237281/1 "2007-08-28T22:03:00Z")

</div>

I would provide the game but due to it’s explicit language, I’ll abstain.

I have a code that randomly generates a random sentence:

```php
on (release) {
    result = a[random(a.length)]+" "+b[random(b.length)]+" "+c[random(c.length)]+" "+d[random(d.length)]+" "+e[random(e.length)]+" "+f[random(f.length)]+" "+g[random(g.length)]+" "+h[random(h.length)]+" "+i[random(i.length)];
}

```

Now on every word, I have a sound clip that I want to play, but how would I code it? I don’t know I would I would assign a sound to a word or how to incorporate it into the coding above.  
Wouldn’t this work?

```php
if(name == "example"){ 
    mysound = new Sound();
mysound.attachSound("example");
mysound.start();}
    }

```
