Music on load

How do you make music play as soon as a script is done loading?

For example:
When a person visits a page, the music plays (like www.sum41.com). Any help would be greatly appreciated.

mySoundObject.onLoad = function(){ this.start();}

ok, I’m new here on the AS scripting, but the code didn’t work.

What exactly do I have to type?

well yes first you would have to define your sound object then load a file into it, then using onLoad you can know when the sound has finished loading and tell it to start, which is what this.start() refers to. ‘this’ represents the sound. So you would have something like

mySoundObject = new Sound();
mySoundObject.loadSound(“mySong.mp3”)
mySoundObject.onLoad = function(){ this.start();}

when mySong.mp3 is loaded (make sure its placed in the same directory as the swf) then it plays

Thanks, but the didn’t work to well. What happened was that the song will not play. It loads ok, but won’t play.

my mistake, simple error in order of operations:

mySoundObject = new Sound();
mySoundObject.onLoad = function(){ this.start();}
mySoundObject.loadSound(“mySong.mp3”);

sorry :wink:

Ok, thank you. Is there a way to make it not loop over a previously playing one (having the same song play twice together)?

you can tell it to stop before telling it to start, so if it is playing already, it will stop itself and then start a new