In this tutorial we will be explaining how to add a sound in the people list so that when somebody comes in or leaves your application a sound will be played.

First of all, open up your application and in the first frame we are going to make the sound object that will be played.

You are going to need a sound to play, so go ahead and bring a sound into your library that you would like played on enter and exit of the application. Once you have the sound file imported, right click on it in the library and choose linkage. Enter a name for you sound and press ok.

Now we need to create the sound object.

inOutSound = new Sound();

//you are going to want to replace "magic" with the name that you gave your sound at the time you set the linkage.

The next thing we need to do is make the function that will play the sound.

function playSound(){

Be careful as when it comes to playing sounds, the first thing that you might think of is to write but this is wrong, we must a start() and stop() a sound.

Next right click on your people list component and go down to line 51 in the actions layer's actionscript. Enter the following code. This will run the function that we just created.


We are running this function inside the sharedObject.onSync function. This function will run everytime the shared object (holding the number of users in the application) gets updated. It will get updated whenever somebody comes or goes from your application.

So there you have it. A quick and easy way to add a sound to your people list.