Creating a music play button to play an mp3 file
Copy link to clipboard
Copied
A good example is from this site: http://terrorbird.com/ under the Jukebox column. Those play buttons are what I need.
Copy link to clipboard
Copied
http://flashspeaksactionscript.com/create-a-mini-music-player-in-as3/
Copy link to clipboard
Copied
On the flash page I will have - say - 5 bands listed. By each will be a song title and then the option to click play or stop. That script didn't seem to work (i posted my issues with it on their page). Any other suggestions?
Copy link to clipboard
Copied
package
{
import flash.display.MovieClip;
import flash.events.*;
import flash.media.*;
import flash.net.URLRequest;
public class SoundLoader extends MovieClip
{
private var isPlaying:Boolean = false;
private var snd:Sound = new Sound();
private var channel:SoundChannel = new SoundChannel();
private var pos:Number = 0;
private var soundVolume:Number = 1;
public function SoundLoader()
{
snd.load(new URLRequest("something.mp3"));
btn_Stop.addEventListener(MouseEvent.CLICK, stopMusic);
btn_Stop.buttonMode = true;
btn_Play.addEventListener(MouseEvent.CLICK, playMusic);
btn_Play.buttonMode = true;
}
private function stopMusic(evt:Event):void
{
channel.stop();
pos = 0;
isPlaying = false;
}
private function playMusic(evt:Event):void
{
if(!isPlaying)
{
channel = snd.play(pos);
btn_Play.visible = false;
btn_Pause.visible = true;
isPlaying = true;
}
}
}
}

Copy link to clipboard
Copied
Do you add this to the button or on an empty frame? I am newbie.. please can anyone point to me a tutorial, because I have the same problem
Copy link to clipboard
Copied
This actually refers to a class file (external flash file).
for example if the class name was: Myclass.as
Store the file in the same directory as your swf and fla. Then in frame one enter:
//first import the class file
import game.SoundLoader;
// create an instance
var myCoolSound:SoundLoader = new SoundLoader();
// now you can use it in your AS
Let us know if you still have a problem.
Message was edited by: >Vee<

Copy link to clipboard
Copied
Thanks Vee, but it is alll greek to me... maybe i should start from scratch. Thanks again

