CLICK THE PLAY BUTTON TO HEAR THE MUSIC (TAKES A FEW SECONDS TO LOAD… WORKS GUARANTEED!)
On this tutorial we create a music player from scratch using the SoundChannel Class in ActionScript 3.0.
DOWNLOAD THIS TUTORIAL WITH COMPLETE FLA SOURCE FILES: $5
DOWNLOAD CARTOON SMART SOUND AND MUSIC TUTORIAL: $20
HERE IS THE SOURCE CODE!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
//The ActionScript 3.0 Sound and Music Player
// by Avraham Saltoun
// solutions at say-web dot com
// FREE to USE, COPY and DISTRIBUTE
var req:URLRequest = new URLRequest ('http://say-web.com/Lesson29SoundPlayer/SmartSound.mp3');
var sound:Sound = new Sound();
// The sound class is the recepient for the
// imported sound file
var controller:SoundChannel;
// the controller sound channel
// will be used to play and stop the music file
function soundLoaded(event:Event):void {
controller = sound.play();
controller.stop();
// this will stop the file from playing
// right after loaded.
play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
}
function playSound(event:MouseEvent):void{
controller = sound.play();
}
function stopSound(event:MouseEvent):void {
controller.stop();
}
sound.addEventListener(Event.COMPLETE, soundLoaded);
sound.load(req); |






2 Responses to “ActionScript 3.0 Lesson 29: Music Player – The Sound Channel”
Trackbacks/Pingbacks