How to add a sound effect .

Note: My screen shots are from my completed program so my line numbers won’t match up with yours.


Intro: We are going to add an event listener to the stage which will play a sound each time a surfer gets eaten.


There are lots of premade sounds in Flash.  Look under Window>Libraries>Common Libraries.


You can also import your own sounds using File>Import.


If you want to get really fancy go to and sign up for a free account.  There are millions of sound fx and tracks.


Getting the Sound

  1. Bring the sound effect you want to use into your library.
  2. Right-click on it and select ‘properties’.
  3. Check the box called “Export for Actionscript
  4. Give it a new name that’s easy to remember.


Adding Sound and Chanel Variables

  1. Open the script in frame 1 of the code layer.
  2. Create an instance variable for each sound you want to use.
  3. Create a SoundChannel instance variable.  




var scream:screamSound = new screamSound();

var channel:SoundChannel;

Playing your sound

  1. This code plays your sound.
  2. Place it in the if-statements where there is a collision.


Note: For things like background music you can drag any sound from your library onto the stage and it will play fine.


What’s Next?

Intro Screen