public class PlayPause extends Sprite { private var _sound:Sound; private var _channel:SoundChannel; private var _playPauseButton:Sprite; private var _playing:Boolean = false; private var _position:int;
public function PlayPause( ) { _sound = new Sound(new URLRequest("song.mp3")); _channel = _sound.play( ); _playing = true;
public function onPlayPause(event:MouseEvent):void { if(_playing) { _position = _channel.position; _channel.stop( ); } else { // If not playing, re-start it at // last known position _channel = _sound.play(_position); } _playing = !_playing; } } }
Related Scripts with Example Source Code in same category :