Hey
I am really close I can feel it.
I am doing something stupid I know.
I have a file where one button simply controls stop and play of a looping audio stream.
(by overlapping the buttons and making them visible or invisible depending on buttonClick)
I have it where it does work for stop/start
but I really need to to Play/Resume.
and I can’t seem to get it to work to save my life
any help would be much appreciated.
thx.
/*this AS3 version attempts to start the music with a 3 sec buffer
then controls the play and stop with a single button.
while looping 100 times*/
var slc:SoundLoaderContext = new SoundLoaderContext(3000); // buffering (3 seconds)
var s:Sound = new Sound(new URLRequest("Sound.mp3"), slc);
s.play(0,100); // (0 buffer, 100x looping)
var lastPosition:Number = 0;
play_btn.addEventListener(MouseEvent.CLICK,playF);
stop_btn.addEventListener(MouseEvent.CLICK,stopF);
var sndTrans:SoundChannel = new SoundChannel();
var st:SoundTransform = new SoundTransform();
play_btn.visible = false;
function playF(e:MouseEvent):void
{
st.volume = .7;
sndTrans.soundTransform = st;
sndTrans = s.play((0,100),lastPosition); // (0 buffer, 100x looping, needing to figue out how to get the lastPosition to work)
play_btn.visible = false;
stop_btn.visible = true;
}
function stopF(e:MouseEvent):void
{
SoundMixer.stopAll();
lastPosition = sndTrans.position;
sndTrans.stop();
play_btn.visible = true;
stop_btn.visible = false;
}
I can get it either / or
if I make the
sndTrans = s.play(0,100); // then it loops but does not pause
if I make it
sndTrans = s.play(lastPosition); then it pauses but dose not loop
so above I have attempted to wrap them inside each other (I have also tried vise versa)
without any luck
any suggestions?
in case it helps I have attached the fla also.