# Hi

**URL:** <https://forum.kirupa.com/t/hi/330601>\
**Category:** Uncategorized\
**Created:** [February 15, 2013, 11:35pm UTC](https://forum.kirupa.com/t/hi/330601 "2013-02-15T23:35:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharon33](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@Sharon33](https://forum.kirupa.com/u/Sharon33)\
**Post date:** [February 15, 2013, 11:35pm UTC](https://forum.kirupa.com/t/hi/330601/1 "2013-02-15T23:35:44Z")

</div>

Hi everyone

i wrote this code that plays music on the background  
but it’s keeps playing also on the next frame i dont want it to play it  
what can i do?  
thank you  
var req:URLRequest = new URLRequest(“song.mp3”);

var isPlaying:Boolean = true;

var snd:Sound = new Sound(req);

var channel:SoundChannel;

var pausePosition:Number = 0;

channel = snd.play(pausePosition);

playBtn2.buttonMode = true;

playBtn2.gotoAndStop(2);

playBtn2.addEventListener(MouseEvent.CLICK, playPause);  
channel.addEventListener(Event.SOUND\_COMPLETE, onPlaybackComplete);

function onPlaybackComplete(event:Event) {

```
    pausePosition = 0;
    channel = snd.play(pausePosition);
    isPlaying = true;
    channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);

```

}

function playPause(event:MouseEvent):void {

```
if (isPlaying == false) {
   channel = snd.play(pausePosition); 
   isPlaying = true; 
   playBtn2.gotoAndStop(2); 
   channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
} else {
   pausePosition = channel.position;
   channel.stop(); // Stop Playing
   playBtn2.gotoAndStop(1); 
   isPlaying = false; 
}

```

}
