Return to Snippet

Revision: 14247
at May 26, 2009 22:47 by Chumps


Updated Code
var soundPlaying:Boolean = false;
var _playPosition:int;


//This is your code here hannah

var snd:Sound = new Sound();
snd.load(new URLRequest("http://www.lazytoolbox.co.uk/05BLACKLOCUST.mp3"));
var channel:SoundChannel = new
SoundChannel();
channel = snd.play(0, int.MAX_VALUE);
soundPlaying = true;

////////////////////////

//////////////////////////
// Stuff I Added in     //
//////////////////////////

pausebuttonname.addEventListener(MouseEvent.CLICK, onPause);

//Code for Pause

public function onPause(Event:MouseEvent):void {
 if(soundPlaying == true) {
   _playPosition = channel.position
  channel.stop();
  soundPlaying = false;
 }
 else
 {
  channel = sound.play(_playPosition);
  soundPlaying = true;
 }




}

Revision: 14246
at May 26, 2009 13:29 by Chumps


Initial Code
var soundPlaying:Boolean = false;
var _playPosition:int;


//This is your code here hannah

var snd:Sound = new Sound();
snd.load(new URLRequest("http://www.lazytoolbox.co.uk/05BLACKLOCUST.mp3"));
var channel:SoundChannel = new
SoundChannel();
channel = snd.play(0, int.MAX_VALUE);
soundPlaying == true;

////////////////////////

//////////////////////////
// Stuff I Added in     //
//////////////////////////

pausebuttonname.addEventListener(MouseEvent.CLICK, onPause);

//Code for Pause

public function onPause(Event:MouseEvent):void {
 if(soundPlaying == true) {
   _playPosition = channel.position
  channel.stop();
  soundPlaying = false;
 }
 else
 {
  channel = sound.play(_playPosition);
  soundPlaying = true;
 }




}

Initial URL

                                

Initial Description

                                

Initial Title
AS3 Sound Listeners

Initial Tags

                                

Initial Language
ActionScript 3