Learn Flash Sound in HTML

Home Food Mates • Members Tutorials Forum Buy Templates Contact Us 

 


Flash Tutorials

   

Tutorial: Flash Sound on HTML Web Pages using JavaScript

 

Free Flash Sound Tutorial


Step 2    <<   Previous      Intro   1   2   JavaScript      Next   >>       >>   Webwasp Mates

 

Step Two: Setting up the Web Page

  1. Open the web page that you want to add sound to.
  2. Add the following code to the head section of your web page:
  3. <script language="JavaScript" src="flashsound.js"></script>
    <script language="JavaScript">
    var mysound = new FlashSound( );
    </script>


  4. In the body section of the same page add:
  5. <script language="JavaScript">
    mysound.embedSWF("
    Sound.swf");
    </script>


    Note: If your Flash Movie is not called: Sound.swf  - you will need to change the code above.

  6. You MUST download the external JavaScript file: flashsound.js

    If you wish to view the content of the JavaScript file: click here

  7. Place this external flashsound.js file along with the Sound.swf Movie in the same location as the web page you want to play sound on.

  8. Every time you want to create a link that will play the sound use one of the following examples of code.


    The code below plays a sound on rollover and stops playing on rollout. The sound will only play once:

    <a href="javascript://" onMouseover = "mysound.gotoAndStop('/SoundPlayer', 'start')"onMouseout = "mysound.gotoAndStop('/SoundPlayer','stop')" onClick = "return false"> Rollover Here To Start Playing A Sound </a>


  9. The next bit of code plays a sound on rollover and stops playing sound on rollout. The sound will play continuously:

    <a href="javascript://" onMouseover = "mysound.gotoAndPlay('/SoundPlayer', 'loop')"onMouseout = "mysound.gotoAndStop('/SoundPlayer','stop')"onClick = "return false"> Rollover here To Start Playing Sound </a>



    To have the sound play once when the page loads use this code:

    <body onLoad="mysound.gotoAndStop('/SoundPlayer', 'start')">



    Or to have the sound play continually, place this code in the Body Tag:

    <body onLoad="mysound.gotoAndStop('/SoundPlayer', 'loop')">


    The following Body Tag will preload the Flash file:

<body onLoad="mysound.gotoAndStop('/SoundPlayer', 'stop')">

    Note: The start, loop and stop in the code above relates to the frame labels that you created in the Flash Movie.

     

You can have different sounds on different links by adding additional sounds in your Flash Movie:


Multiple sounds and loops have been added for different links on the web page.

Then refer to each individual sound or loop like so:

    <a href="javascript://" onMouseover = "mysound.gotoAndPlay('/SoundPlayer', 'start2')"onMouseout = "mysound.gotoAndStop('/SoundPlayer','stop')"onClick = "return false"> Rollover here To Start Playing Sound </a>

    The above plays a sound (Label start2 sound) on rollover and stops playing on rollout. The sound will only play once.

    <a href="javascript://" onMouseover = "mysound.gotoAndPlay('/SoundPlayer', 'loop2')"onMouseout = "mysound.gotoAndStop('/SoundPlayer','stop')"onClick = "return false"> Rollover here To Start Playing Sound </a>

    The above plays a sound (Label loop2 sound) on rollover and stops playing on rollout. The sound will only play once.


You can download an example web page to see how to code your web page here

For advanced users who want to experiment, the following is a list of commands that you can use:

mysound.gotoAndStop('/SoundPlayer', 'start')"
mysound.gotoAndPlay('/SoundPlayer', 'start')"
return false

For other tutorials on how to use this technique:

www.flashsoundapi.com

www.devx.com

 

Please indicate what you thought of this tutorial 
10 is the best: 
10 9 8 7 6 5 4 3 2 1

         

Step 2    <<   Previous      Intro   1   2   JavaScript      Next   >>       >>   Webwasp Mates


Webwasp Community: Webwasp Mates & Dates

Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates

 Top of Page Home Food Mates Members Tutorials Forum Buy Templates Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.