# How to play sounds depending on a value in a movie clip?

**URL:** https://forum.kirupa.com/t/how-to-play-sounds-depending-on-a-value-in-a-movie-clip/331891
**Category:** flash
**Created:** [November 16, 2013, 4:41pm UTC](https://forum.kirupa.com/t/how-to-play-sounds-depending-on-a-value-in-a-movie-clip/331891 "2013-11-16T16:41:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![razer56](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@razer56](https://forum.kirupa.com/u/razer56)
#### Post date: [November 16, 2013, 4:41pm UTC](https://forum.kirupa.com/t/how-to-play-sounds-depending-on-a-value-in-a-movie-clip/331891/1 "2013-11-16T16:41:23Z")

</div>

[COLOR=#000000][FONT=Arial]I have a movie clip layer (in main timeline) named “options\_mc” inside of it; it contains a dynamic text field (onoff\_txt) that changes to 0 or 100 when a button (sound\_btn) is clicked. If the value is 100, then sounds should play…if it is 0, sounds should not play. On a different layer in a movie clip on the main timeline, I have the sound channel “tchannel” I added a function in that same layer which goes like this:

```auto
[/FONT][/COLOR][COLOR=#2B91AF][FONT=Consolas]CheckSound[/FONT][/COLOR][COLOR=#000000][FONT=Consolas]();[/FONT][/COLOR]
[COLOR=#00008B]function[/COLOR] [COLOR=#2B91AF]CheckSound[/COLOR]():[COLOR=#00008B]void[/COLOR]
 {
 [COLOR=#00008B]if[/COLOR](options_mc.onoff_txt == [COLOR=#800000]100[/COLOR])
 {
 tchannel = theme.play([COLOR=#800000]0[/COLOR],[COLOR=#800000]9999[/COLOR]);
 }
 [COLOR=#00008B]else[/COLOR] [COLOR=#00008B]if[/COLOR](options_mc.onoff_txt == [COLOR=#800000]0[/COLOR])
 {
trace([COLOR=#800000]"noplay"[/COLOR]);
 } [COLOR=#000000][FONT=Consolas] [/FONT][/COLOR][COLOR=#000000][FONT=Consolas]}[/FONT][/COLOR][COLOR=#000000][FONT=Arial]

```

[/FONT][/COLOR][COLOR=#000000][FONT=Arial]The sound does not play at all, nor does a trace statement appear. What is wrong with my code?[/FONT][/COLOR]
