I can think of  2 possibilities causing your trouble:

1. By using 1 name for all your Sound objects, each one is over-writing the one before it. So what you end up with is 4 references to the same Sound, the last one in the loop. 2. It's possible that you're trying to play the sounds before they're completely loaded.

I played with your code a bit and this works:

<code>
var mySounds:Array = new Array();
var sPath:String = "../mp3/";

mySounds[0] = sPath+"soundD_DIP_you_know_this_word.mp3";
mySounds[1] = sPath+"soundD_NAR_a.mp3";
mySounds[2] = sPath+"soundD_NAR_a_(art).mp3";
mySounds[3] = sPath+"soundD_NAR_a_capital_b_looks_like_this.mp3";

var sounds_array:Array = new Array();
var sBaseName:String = "sound";

// load all sounds in loop
function loadSounds() {
   trace("loadSounds");
   for (var i:Number = 0; i<mySounds.length; i++) {
       var sRef = _root;
//        var testSound:Sound = new Sound(sRef);
       this["testSound"+i] = new Sound(sRef);
       var rfcSound:Sound = this["testSound"+i];
       rfcSound.onLoad = function(success){
           if(success) {
               // prove the load is complete
               trace(this+": dur:"+this.duration);
           } else {
               trace("Not loaded yet");
           }
       };
       rfcSound.loadSound(mySounds[i], False);
       sounds_array.push(rfcSound);
   }
}
loadSounds();
// ----
// test to play sounds
// make sure the start() call comes after the load is complete
onInterval = function(){
   clearInterval(nbrInterval)
   for (var i in sounds_array) {
       trace("tick");
       sounds_array[i].start();
   }
};
nbrInterval = setInterval (this, "onInterval", 1000);

</code>
hth,
Bob

Marc Hoffman wrote:

Offhand I'm not sure of the problem -- anyone else have an idea?

It could be as simple as the use of "False" rather than "false" in that last line. But I also wonder about two things:

First, I would expect a trace of the mySounds array to return a list of paths to the sounds, not "[Object Object]."

Second, I'm not sure of the implications of using _root as the scope for every testSound object where you're re-using the name for the Sound object. Since you're calling them in a single action sequence, I don't know if Flash has a chance to start loading one sound before it's replaced by the action to load another sound. At best, loading them sequentially into the same Sound object means you can only access the last sound to be loaded. So you might try assigning a unique name to each sound object.

- Marc


At 05:49 AM 3/10/2006, murder design wrote:

paths are ok, playing them without dynamically loading and placing into
arrays is fine. the trace of the array results in: [Object Object] four
times, however no play. here is my complete code, no errors, but no results: when i give each sound object the same name, does that matter if there is a pointer within an array element for each one? am i going about this wrong...


var mySounds:Array = new Array();
var sPath:String = "sound/loops/";
mySounds[0] = sPath + "Accident-Broadkas-8819.mp3";
mySounds[1] = sPath + "5-jakkob-2501.mp3";
mySounds[2] = sPath + "albert-Mikkel_M-204.mp3";
mySounds[3] = sPath + "delerium-queali-1634.mp3";

var sounds_array:Array = new Array();
var sBaseName:String = "sound";

// load all sounds in loop
function loadSounds() {
 for (var i:Number = 0; i < mySounds.length; i++) {
  sRef = _root;
  var testSound:Sound = new Sound(sRef);
  sounds_array.push(testSound);
  testSound.loadSound(mySounds[i], False);
 }
}



_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



--
Thanks,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bob Leisle Headsprout Software & Engineering
http://www.headsprout.com
Where kids learn to read!

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to