# Trying to load and play sound with buttons

**URL:** <https://forum.kirupa.com/t/trying-to-load-and-play-sound-with-buttons/305524>\
**Category:** flash\
**Created:** [February 26, 2010, 2:44pm UTC](https://forum.kirupa.com/t/trying-to-load-and-play-sound-with-buttons/305524 "2010-02-26T14:44:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chusa83](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@chusa83](https://forum.kirupa.com/u/chusa83)\
**Post date:** [February 26, 2010, 2:44pm UTC](https://forum.kirupa.com/t/trying-to-load-and-play-sound-with-buttons/305524/1 "2010-02-26T14:44:30Z")

</div>

Hi everybody!

I’ve been trying to make some buttons to load and play (in stream) determined sounds, but Error compiler shows error 2007, and I really don’t understand why listener it’s getting a null value. Can anyone help me?:hang:

Here is the code:

```auto

import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.net.URLRequest;
var s:Sound = new Sound();

var tocarSonido = function (req:String){
    //trace (req);
var context:SoundLoaderContext = new SoundLoaderContext(1000, true);
s.load(new URLRequest(req+".mp3"), context);
s.play();
}

a_btn.addEventListener(MouseEvent.CLICK, tocarSonido("a"));
b_btn.addEventListener(MouseEvent.CLICK, tocarSonido("b"));

```
