Computer Science Canada

problems playing externally loaded sounds (mp3's)

Author:  wthef [ Wed Nov 30, 2005 10:49 pm ]
Post subject:  problems playing externally loaded sounds (mp3's)

in the root of my movie i have the following code:
code:
//Sound Code
soundtrack = new Array("Path.mp3", "Hold.mp3", "Stardance.mp3");
soundtracklable = new Array();

for (x=0; x<=2; x++) {
        soundtracklable[x] = new Sound();
        soundtracklable[x].loadSound(soundtrack[x], false);
}
clicked = 3;
volumeslider.onMouseMove = function() {
        var currentVolume = this.position._x/2;
        soundtracklable[clicked].setVolume(currentVolume);
};

then in a movie clip called tracksel i have the following
(org is a movieclip lke a button)
code:
org.onLoad = function() {
        org._alpha = 20;
};
org.onRollOver = function() {
        org._alpha = 100;
        org.gotoAndPlay(2);
};
org.onRollOut = function() {
        org._alpha = 20;
        org.gotoAndStop(1);
};
org.onRelease = function() {
        stopAllSounds();
        trace(_root.soundtracklable[0]);
        trace(_root.soundtrack[0]);
        _root.soundtracklable[0].start(0, 999);
        _root.clicked = 0;
};

then i have the above code for 2 more movie clips like org called gray and lgray, here is the respective code:
code:
gray.onLoad = function() {
        gray._alpha = 20;
};
gray.onRollOver = function() {
        gray._alpha = 100;
        gray.gotoAndPlay(2);
};
gray.onRollOut = function() {
        gray._alpha = 20;
        gray.gotoAndStop(1);
};
gray.onRelease = function() {
        stopAllSounds();
        trace(_root.soundtracklable[2]);
        trace(_root.soundtrack[2]);
        _root.soundtracklable[2].start(0, 999);
        _root.clicked = 2;
};
code:
lgray.onLoad = function() {
        lgray._alpha = 20;
};
lgray.onRollOver = function() {
        lgray._alpha = 100;
        lgray.gotoAndPlay(2);
};
lgray.onRollOut = function() {
        lgray._alpha = 20;
        lgray.gotoAndStop(1);
};
lgray.onRelease = function() {
        stopAllSounds();
        trace(_root.soundtracklable[1]);
        trace(_root.soundtrack[1]);
        _root.soundtracklable[1].start(0, 999);
        _root.clicked = 1;
};

the problem is that only one song plays (stardance.mp3)
all the songs load. i know this because if i change the
code:
soundtracklable[x].loadSound(soundtrack[x], false);
line to
code:
soundtracklable[x].loadSound(soundtrack[x], true);

i can hear all 3 songs play at load up, but not when org or lgray buttons are pressed, but for some reason the songs "path" and "hold" will not play, only stardance.
does anyone know or can see what i am doing wrong?
p.s. if the songs are with in the flash library and i use the attachsound method the buttons work fine, the problem seems to be with the loading or my arrays.
-thanx wthef


: