# Sound stop() issue

**URL:** <https://forum.kirupa.com/t/sound-stop-issue/252384>\
**Category:** Uncategorized\
**Created:** [February 19, 2008, 5:32pm UTC](https://forum.kirupa.com/t/sound-stop-issue/252384 "2008-02-19T17:32:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![levidyllan](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@levidyllan](https://forum.kirupa.com/u/levidyllan)\
**Post date:** [February 19, 2008, 5:32pm UTC](https://forum.kirupa.com/t/sound-stop-issue/252384/1 "2008-02-19T17:32:08Z")

</div>

I have the following code, its on the first frame on my flash and I have two buttons at the moment, but when I press one the sound start off ok but then when I press the other button it plays over the ither so it sounds terrible, so I placed a stop in the next sound function but this i snow giving issues:

```auto

 import flash.display.*;
 import flash.media.*;
 import flash.net.*;
 import flash.text.*;
 import flash.events.*;
 
    var _sound:Sound;
   var _channel:SoundChannel;
   
   // song button functions (buttons found on the main fla file.
   songOne.addEventListener(MouseEvent.CLICK, one);
    function one(event:MouseEvent):void {
     var nextSong:String = "http://...to mp3";
     songChange(nextSong);
   }
   
   songTwo.addEventListener(MouseEvent.CLICK, two);
    function two(event:MouseEvent):void {
     var nextSong:String = "http://...to mp3";
     songChange(nextSong);
   }
   
   /// the next song function
   function songChange(nextSong:String):void {
   _channel.stop();
   _sound = new Sound(new URLRequest(nextSong));
   _sound.play();
   }

```

the error I get is when i put this in \_channel.stop();…

> TypeError: Error #1009: Cannot access a property or method of a null object reference.  
> at jukeboxAS3\_ALLONE\_2\_fla::MainTimeline/songChange()  
> at jukeboxAS3\_ALLONE\_2\_fla::MainTimeline/one()

with out the stop they will simply keep playing over each other.

Any ideas I read that I simply need to add a stop to my channel variable but this does not work but throws up the error.

thank you
