PDA

View Full Version : the sound doesn't start


anca.andreica
06-11-2004, 07:47 PM
I have this problem with the sound that doesn't start. I load it (I'm using a preloader for it) after it is loaded, it doesn't always start. Sometimes it does, sometimes it doesn't. Can you please give me a hint?


song1.loadSound(song1.mp3");
preloadNow=1;
mySoundLoading=0;
_root.loadbar._visible=true;

this.onEnterFrame = function ()
{ mySoundBytesTotal =_root.song1.getBytesTotal();
mySoundBytesLoaded=_root.song1.getBytesLoaded();
if (preloadNow==1 && mySoundBytesLoaded>0) {
mySoundLoading=Math.round((mySoundBytesLoaded/mySoundBytesTotal)*100);
_root.percentLoadedText="Loading..."+mySoundLoading+"%";
if (mySoundLoading==100) {
preloadNow=0;
_root.loadbar._visible=false;
_root.song3.stop();
_root.song2.stop();
_root.song1.start();
}
}
}


well, the loadbar is no longer visible, so this means that mySondLoading reach 100, but the song doesn't always start. the second time when i push the button to play the song, it starts instantly, because it is already on the computer.

thanx for your help,
anca

FrozenMedia
06-12-2004, 08:57 AM
Just a couple of quickies:

I've added AS tags to your code, when you are posting, remember to hit the "AS" button when you are about to paste any code in.

Your first line doesn't have an initial " mark within the loadSound. But you probably have in your actual code right?

Remember to check for bytesLoaded > 4 as that is the minimum size of an empty movieclip.

Remember to check for "totalPercent >= 100" not just "==100" because glitches can escape this value.

Trace out your total percent loaded to see that it really does end up == 100.

Finally, remember to assign this.onEnterFrame = undefined; when the sound has been loaded to stop the sound being start()'ed every frame (this may enable you to get rid of your "preloadNow" variable.

If none of this sorts it, please give us a shout, or even if it does!


Rich

anca.andreica
06-21-2004, 09:02 PM
First of all, I don't know what do you mean by "AS tags". Could you please explain to me?

I do have the initial " mark within the loadSound in my actual code.

It doesn't make any sense to change the condition, because I have tested the code and the condition "totalPercent == 100" becomes true.

I have made all the other changes you've told me to, but it's still not working.

Anca