PDA

View Full Version : Combine two javascripts



Atrytonopsis
12-21-2005, 05:29 PM
Hello, I am an amateur webmaster and can't figure out how to combine two javascripts. I've looked all over the internet and have found a couple of sites where this is discussed, but I guess for me it is too complicated and need it at a JS Kindergarten level! What I want is for my piano menu to play sound on rollover and look like it is really playing. :D I can do the rollover effect OR the sound but I can't make both codes work at the same time. I found a site that discusses the problems of combining to JS scripts and how to fix but I don't understand it!!! .....Can any of you help??? Here are two possible scripts that would need to be combined: http://www.dynamicdrive.com/dynamicindex15/domroll.htm and http://www.dynamicdrive.com/dynamicindex11/javascriptsound.htm

This is my test site that I can't get sound to. http://www.delraybeachchorale.org/test.htm

Maybe some nice person out there can help a damsel in distress??? ;)

jscheuer1
12-21-2005, 05:55 PM
Oddly enough, you will be better off using the MM_swapImage()/MM_swapImgRestore() as you have it on your demo page and forgetting about the DD rollover script. To add the sound script, simply follow the installation instructions on its demo page, only add its call to the existing mouseover call from MM_swapImage(), ex:


onMouseOver="MM_swapImage('Image2','','key2down.jpg',1);playsound(soundfile);"

Atrytonopsis
12-22-2005, 07:20 PM
THANK YOU!!!!! Look how cool! http://www.delraybeachchorale.org/test.htm
I will update with real notes on the second octave soon! Your are awesome! I think that I'd been missing that final semi colon AFTER the sound.....did the one in between but not after. Thanks for your quick reply. Happy holidays!!!!

BaptistKitty
12-26-2005, 05:13 PM
I added

;playsound(tick.wav);

to

onMouseOver="MM_nbGroup('over','Bibles','BiblesS.jpg','Bibles.jpg',1)

to get

onMouseOver="MM_nbGroup('over','Bibles','BiblesS.jpg','Bibles.jpg',1);playsound(tick.wav);

well... now its just saying that tick is undefined....

I'm trying to do something similar to what Atrytonopsis is trying to do but its a menu...

am I doing it wrong then?

thanks

jscheuer1
12-26-2005, 05:25 PM
Assuming all else is right with your code, tick.wav (being a literal) needs to be quoted (oh, and the event's function needs a closing quote):


onMouseOver="MM_nbGroup('over','Bibles','BiblesS.jpg','Bibles.jpg',1);playsound('tick.wav');"

BaptistKitty
12-26-2005, 06:04 PM
When I mouseover the <a href for this, I get a js error "Object Expected"


onMouseOver="playsound('tick.wav');MM_nbGroup('over','Bibles','BiblesS.jpg','Bibles.jpg',1);"

jscheuer1
12-26-2005, 08:00 PM
That's what I was talking about when I said:


Assuming all else is right with your code

To really tell, I'd need to see the page. Most likely, you do not have one of the functions mentioned in the event defined, or defined but with error(s). Most likely it is the 'playsound()' function and most likely it is missing from your page. The 'playsound()' function is, I believe, a DD script and (be it a DD script or any other script) for it to work, the code for it must be on or available to your page. But, that's just the most likely scenario:

.