ActionScript 3.0 Lesson 29: Music Player – The Sound Channel

Tue, Sep 8, 2009

ActionScript

CLICK THE PLAY BUTTON TO HEAR THE MUSIC (TAKES A FEW SECONDS TO LOAD… WORKS GUARANTEED!)

This movie requires Flash Player 9


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);

Related Articles:

, , , , , , , , , , , , , , , , , , , , , , , , ,

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


Trackbacks/Pingbacks

Leave a Reply

You must be logged in to post a comment.

My name is Avraham Saltoun, and I live in Jerusalem, Middle East. I am currently on my mid  40's and I am a computer programming technician. Here you will find over one hundred quality video tutorials on Actionscript, and yes, I give online support for aspiring programmers, and pros as well, sharing screen on skype and delivering source code by email, click the button for live flash actionscript support now!

 
oDesk Certified Action Script Programmer
oDesk Certified Adobe Flash CS3 Designer
oDesk Certified Adobe Photoshop 6.0 Designer
Skype Me™!

$7.49 .Com! Score Savings Cartoon Smart Tutorials


1,260
Unique Visitors
Previous 30 Days
Powered By Google Analytics