# Passing var name into sound object

**URL:** <https://forum.kirupa.com/t/passing-var-name-into-sound-object/219356>\
**Category:** flash\
**Created:** [March 15, 2007, 9:26pm UTC](https://forum.kirupa.com/t/passing-var-name-into-sound-object/219356 "2007-03-15T21:26:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dru\_nasty](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dru\_nasty](https://forum.kirupa.com/u/dru_nasty)\
**Post date:** [March 15, 2007, 9:26pm UTC](https://forum.kirupa.com/t/passing-var-name-into-sound-object/219356/1 "2007-03-15T21:26:56Z")

</div>

```auto

_global.myVar = "";

varSound = new Sound();
varSound.attachSound(_global.myVar);

function playSound(arg){
	arg.start(0,1);
}

sound_btn.onRelease = function(){
	playSound(varSound);
             //myVar traces out as sfx2 after clicking button in code below so i don't get why it wont play
	trace(_global.myVar);
}

```

I have the global myVar set as nothing to start. Within my movie a level deeper on click of a button i’m trying to set the global with this

```auto

preview_btn.onRelease = function(){
	//trying to set variable here, it traces out as sfx2
	_global.myVar = "sfx2";
	trace("i just updated the root var myVar to "+ _global.myVar);
}

```

But the sound doesn’t play when clicking sound\_btn. So i don’t know if it has something to do with trying to pass a variable into the declaration of the sound object or what. Can someone help?
