In order to play a sound, you either need to have the sound in the library, or play the sound from a URL.
In this example we will play a sound from a URL..
Write the code as shown below:
btnWin.addEventListener(MouseEvent.CLICK, winner);
function winner(e:MouseEvent):void {
var sound:Sound=new Sound();
var req:URLRequest = new URLRequest("http://www.zebra0.com/flash/resources/win.mp3");
sound.load(req);
sound.play();
} //winner
Download the finished movie
INDEX, Timer Class, Sound Class, URLRequest to play a sound, Start and Stop a Sound with a Channel, URLRequest to Open the Browser, Add New Child at Runtime, List to download classes
Next lesson: Document Class