Flash actionscript 3.0: how to play and pause a external mp3 file in flash using actionscript 3.0

how to play and pause a external mp3 file in flash using actionscript 3.0

Posted by Sankar.G | Posted in | Posted on 9:01 AM

you can load a external mp3 file using Action script 3.0
AS3.0
Code:
var req:URLRequest=new URLRequest("E:/Songs/sound.mp3");
var s:Sound=new Sound();
var so:SoundChannel=new SoundChannel();
var pos:Number;
b1_btn.addEventListener(MouseEvent.CLICK,fun);
b2_btn.addEventListener(MouseEvent.MOUSE_DOWN,fun1);
b2_btn.addEventListener(MouseEvent.MOUSE_UP,fun2);
function fun2(e2:Event)
{
so=s.play(pos);
}
function fun1(e1:Event)
{
pos=so.position;
trace("position:"+pos);
so.stop();
}
function fun(e:Event)
{
s.load(req);
so=s.play();
}
This is the code you can play a sound from any location but dont forget to put right slash to get the file from local

Comments (3)

Thanks alot!!! it worked very well and it helped us alot!!1 expecting more

Great did search a lot for this type of code and finally found it ,,, do you have a site or page where you do place this help posts ..... let me know ,,,, santiagojpc@hotmail.com

Thanks Lioyd and santiagojpo
if i done any new upload sure i will send mail to you