# Help using array to call embedded sounds

**URL:** <https://forum.kirupa.com/t/help-using-array-to-call-embedded-sounds/234953>\
**Category:** Uncategorized\
**Created:** [August 7, 2007, 1:22pm UTC](https://forum.kirupa.com/t/help-using-array-to-call-embedded-sounds/234953 "2007-08-07T13:22:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![clouis](https://avatars.discourse-cdn.com/v4/letter/c/90ced4/32.png) [@clouis](https://forum.kirupa.com/u/clouis)\
**Post date:** [August 7, 2007, 1:22pm UTC](https://forum.kirupa.com/t/help-using-array-to-call-embedded-sounds/234953/1 "2007-08-07T13:22:30Z")

</div>

hi everyone,  
i’ve been using attachmovieclip and sound methods in AS2 successfully, but not sure how to do it in AS3.

it’s for a free Lao language learning website, and it has a box that the user clicks on to cycle through the characters.  
I want them to be able to click on the symbol and for it to play the relevant embedded sound from the library. (NB I want to use embedded sound so that ppl can download the swf for offline use).

[INDENT]consarray[0] = [“aw”, “\u0EAD”];  
consarray[1] = [“baw”, “\u0E9A”];  
[/INDENT]  
I cycle through an array formatted like above, with the second item being the unicode ref.  
What I was thinking I needed to do was within the event listener I have setup at the moment (that works) is use the sound method.

So I think I need to use something like the following, or have the variable outside, to be honest I’m not quite sure.  
[INDENT]function onClick(event:\*):void {  
var soundstring = “cf”+(consarray[arrayposition][0])  
trace(soundstring);  
var channel:SoundChannel = soundstring.play();  
}  
[/INDENT]I guess I need to know if

1. I need to initialise a variable for each of the embedded sounds in my library? (I’ll end up having around 200!!)
2. if so, is there a quick way of doing this?
3. if I have a statement like this  
[INDENT]var channel:SoundChannel = soundstring.play();  
[/INDENT]can soundstring be a string variable that I can call? I get an error saying a value cannot be a function, which I guess answers my question with a no, but then how do I do this?

Apologies I have been trying to read the tutorials and FAQs but I’m still not 100% on this.

Any recommendations/help would be greatly appreciated.

Thanks
