# Creating sound object with loop

**URL:** <https://forum.kirupa.com/t/creating-sound-object-with-loop/294610>\
**Category:** Uncategorized\
**Created:** [August 17, 2009, 3:19pm UTC](https://forum.kirupa.com/t/creating-sound-object-with-loop/294610 "2009-08-17T15:19:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tzachikk](https://avatars.discourse-cdn.com/v4/letter/t/4491bb/32.png) [@tzachikk](https://forum.kirupa.com/u/tzachikk)\
**Post date:** [August 17, 2009, 3:19pm UTC](https://forum.kirupa.com/t/creating-sound-object-with-loop/294610/1 "2009-08-17T15:19:58Z")

</div>

hei.  
I’m building a web flash 8 app with an animated nurse that talks and help the user in different events. the voices sit in a external folder and i load them using load sound method.  
It works fine as a desktop app, but when testing the movie on slow download (DSL 32 KB/s) I realized that i must load all the sound before i can play the animation.

problem nr.1:  
How do i create folowing sound objects (voice\_0, voice\_1, voice\_2…) using a loop?

I’ve tried this, but it doesn’t work

[COLOR=“DimGray”]for (i=0;i\<numVoices;i++)  
{  
var this[“voice\_”+i]:Sound=new Sound;  
}[/COLOR]

## It says: Identifier expected ???

problem num.2:  
let’s say i declared and instansiated the sound variable outside the loop.  
trying to build a loop to load them and get onLoad event (on the same loop) doesn’t seemed work for me:  
[COLOR=“rgb(105, 105, 105)”]this.loadAllVoices = function() {  
for (i=0; i\<numVoices; i++) {  
this[“voice\_”+i].onLoad = function(success:Boolean):Void {  
if (success) {  
trace(“success: “+i);  
trace(helpVoice1+“Loaded”);  
}  
this[“voice\_”+i].loadSound(“voice/”+“English”+”/”+\_parent.userMenuNode.childNodes[3].childNodes\*.firstChild.nodeValue+".mp3", false);  
};  
}  
};[/COLOR]

Does anyone know 🙂 ?
