Hi there.
I am building a flash site that in one of the sections requires inidividual mp3 playback.
I have 4 artists, all on the same timeline, distinguished by frame labels.
I have created an mp3 player, with the attached code:
var music:Sound = new Sound(new URLRequest("http://www.sarah-hammond.co.uk/Let%20Go.mp3"));
var sc:SoundChannel;
var isPlaying:Boolean = false;
var pos:Number = 0;
var soundVolume:Number = 1;
var muted:Boolean = false;
mute_mc.buttonMode = true;
volume_mc.slider_mc.buttonMode = true;
pause_btn.addEventListener(MouseEvent.CLICK, pauseMusic);
function pauseMusic(e:Event):void
{
if (isPlaying)
{
pos = sc.position;
sc.stop();
isPlaying = false;
}
}
stop_btn.addEventListener(MouseEvent.CLICK, stopMusic);
function stopMusic(e:Event):void
{
if(sc != null)
{
sc.stop();
pos = 0;
isPlaying = false;
}
}
play_btn.addEventListener(MouseEvent.CLICK, playMusic);
function playMusic(e:Event):void
{
if (!isPlaying)
{
sc = music.play(pos);
isPlaying = true;
}
}
//---VOLUME SLIDER---//
var dragging:Boolean = false;
var rectangle:Rectangle = new Rectangle(0,0,100,0);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function dragIt(e:Event):void
{
volume_mc.slider_mc.startDrag(false,rectangle);
dragging = true;
volume_mc.slider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
}
function dropIt(e:Event):void
{
if (dragging)
{
volume_mc.slider_mc.stopDrag();
volume_mc.slider_mc.removeEventListener(Event.ENTER_FRAME, adjustVolume);
dragging = false;
}
}
function adjustVolume(e:Event):void
{
mute_mc.gotoAndPlay("On");
soundVolume = volume_mc.slider_mc.x / 100;
var st:SoundTransform = new SoundTransform(soundVolume);
if (sc != null)
{
sc.soundTransform = st;
muted = false;
}
}
mute_mc.addEventListener(MouseEvent.CLICK, mute);
function mute(e:MouseEvent):void
{
if (sc != null)
{
var st:SoundTransform;
if (muted)
{
st = new SoundTransform(soundVolume);
sc.soundTransform = st;
mute_mc.gotoAndStop("On");
muted = false;
}
else
{
st = new SoundTransform(0);
sc.soundTransform = st;
mute_mc.gotoAndStop("Mute");
muted = true;
}
}
}
What I am hoping to do, is have the actionscript and mp3 player on the main timeline, and to call a different mp3 url on different frame labels.
Can anyone suggest a code I could add to the attched to do so?
I guess I need to stop the streaming of one url before calling another too,
Many thanks for any help anyone can give me-Im going CRAZY with confusion!!!
Doodark x