Sound play/pause

//AS3 code
download file - http://www.mediafire.com/?gcvx8s16ui2id0z
var pausePoint:Number = 0.00;
var isPlaying:Boolean;
var soundChannel:SoundChannel = new SoundChannel();

var mySound:Sound = new mySong();
isPlaying = true;
soundChannel = mySound.play();
play_btn.addEventListener(MouseEvent.CLICK, MP3_music);

function MP3_music(event:MouseEvent):void {

if (isPlaying) {
pausePoint = soundChannel.position;
soundChannel.stop();
isPlaying = false;

} else {

soundChannel = mySound.play(pausePoint);
isPlaying = true;

}
}


// AS2 code

var snd1mc:MovieClip = this.createEmptyMovieClip("snd1mc",this.getNextHighestDepth());
var rakSound:Sound = new Sound(snd1mc);
rakSound.attachSound("rakbacksound");
rakSound.start(0,999);
rakSound.setVolume(25);

on (release) {
play();
fastsaver_m.play();
btn_stop._visible = true ;
btn_play._visible = false ;
_root.rakSound.start(myMusicPosition,0);
}

on (release) {
stop();
fastsaver_m.stop();
btn_stop._visible = false ;
btn_play._visible = true ;

myMusicPosition=_root.rakSound.position/1000;
_root.rakSound.stop("rakbacksound");

}

0 comments:

Post a Comment