Our Swish tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website.  Home Flash & Swish Swish Tutorials Play and stop control in java script

Play and stop control in java script


1. Add this code inside the body tags:

<script language="Javascript">

n = (document.layers) ? 1:0
ie = (document.all) ? 1:0
function play_sound() {
   if (n) document.thesound.play(false)
   if (ie) {
       document.thesound.stop()
       document.thesound.play()
   }
}
function stop_sound() {
   document.thesound.stop()
}
</script>
<embed src="http://your.host.com/midifile.mid" hidden=true autostart="false" mastersound name="thesound">

2.Create a new swish movie and name it whatever you want

3. Create some stop and play buttons, text, etc

4. Insert this in the action of the play button:

on [release]
 Goto URL: javascript:play_sound();

5. Insert this in the action of the stop button:

on [release]
 Goto url: javascript:document.thesound.stop()

The music file can be anything from midi, wav, or an mp3 file. The most interesting part is, it's from and external source and does not use any plugin.

I'll create a web site with the tutorial because the formating doesn't seem right.



Author's URL: timdav83
Final results of our readers
New!
Passed through all the steps? Share your result!
Your result will be premoderated.
Please make sure you choose the right image.
 
 



Captcha

*Required fileds
Our Swish tutorials provide you with step-by-step instructions on how to create beautiful Flash animations and integrate them into your website. More Swish Tutorials: Featured Materials | Fresh Materials | More Swish Tutorials at FlashPerfection.com

Reader's comments
comments MBO July 26, 2010 says:
thanks for this tutorial ^_^
Reply
Add comments to "Play and stop control in java script"

Captcha