Skip to main content
Participating Frequently
July 21, 2009
Question

turn off auto play

  • July 21, 2009
  • 1 reply
  • 526 views

i have this code for my music player but i only want to music to play if the play button is pushed. what should i add or how should i modify this code to make that happen?

var url:String = "";
var urlRequest:URLRequest = new URLRequest(url);
var sound:Sound = new Sound();
sound.load(urlRequest);
var sc:SoundChannel=sound.play();

var startTime:uint=0;


play_btn.addEventListener(MouseEvent.CLICK,playF);
stop_btn.addEventListener(MouseEvent.CLICK,stopF);
pause_btn.addEventListener(MouseEvent.CLICK,pauseF);


function playF(e:Event){
sc=sound.play(startTime);
}

function stopF(e:Event){
sc.stop();
startTime=0;
}


function pauseF(e:Event){
startTime=sc.position;
sc.stop();
}

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
July 21, 2009

Change: var sc:SoundChannel=sound.play();

to:         var sc:SoundChannel;