Click to See Complete Forum and Search --> : java script help
Milkman
04-03-2001, 05:47 PM
hi everyone,
I need a preload script to preload sounds so that each time someone clicks on a picture, this sound will take the characteristic of the bgsound. I have the actual sound code written with the onCLick function, but i need these sounds to preload so there will be no time delay. thanks.
------------------
"There are two steps to success: 1. Never tell everything you know 2. See #1"
Grizzly
04-03-2001, 07:38 PM
This is a generic image preloader, but it should work for sounds just the same. Simply change what's between the quotes below to whatever sounds you want preloaded.
<script language=javascript>
<!--- //
imgNames = new Array(
"/sounds/yoursound.wav",
"/sounds/yoursound2.wav"
)
loadImgs = new Array()
for(i=0; i < imgNames.length; i++) {
loadImgs[i] = new Image;
loadImgs[i].src = imgNames[i];
}
// --->
</script>
Milkman
04-03-2001, 08:16 PM
thank you!
------------------
"There are two steps to success: 1. Never tell everything you know 2. See #1"
Grizzly
04-03-2001, 08:20 PM
My pleasure! Lemme know if it works or not! http://www.sharkyforums.com/ubb/tongue.gif
Milkman
04-03-2001, 09:40 PM
thank you, the preload script worked well in ie. however, i still can't get my sounds to play in netscape using an onClick="bgsound.src=''...i am not even sure if netscape supports bgsound??? thoughts? thanks.
------------------
"There are two steps to success: 1. Never tell everything you know 2. See #1"
Grizzly
04-03-2001, 10:24 PM
Yeeeaaaah....Netscape's always been a little tricky with playing sounds. I'm sorry but it really is a bad browser. I really wouldn't know how to help you in that aspect...I've personally never found a way to get Netscape to play sounds on mouseEvents properly, outside of doing the whole thing in Flash of course. Best of luck to you buddy http://www.sharkyforums.com/ubb/biggrin.gif
Milkman
04-04-2001, 06:30 PM
aside from my planned international boycott on netscape (because it does not support vbscript, css, some javascript and html), and have a few ideas using the embed src tag and arrays to make an onClick play bgsound thing work. I will post it when I figure it out. Thanks for your help with the preload.
------------------
"There are two steps to success: 1. Never tell everything you know 2. See #1"