# This code seems to be not working?

**URL:** <https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013>\
**Category:** Uncategorized\
**Created:** [September 22, 2004, 7:41am UTC](https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013 "2004-09-22T07:41:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanvi](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@tanvi](https://forum.kirupa.com/u/tanvi)\
**Post date:** [September 22, 2004, 7:41am UTC](https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013/1 "2004-09-22T07:41:06Z")

</div>

[color=navy]on (press) {  
\_root.mySlider.mySound.stop();  
if (\_root.mySlider.mySound.stop()) {  
\_root.dl = “Sound is Stopped…”;  
} else {  
\_root.dl = “playing”;  
}  
}  
[/color]  
[color=black]this is on the stop\_btn to stop music on playing and also show the text “Sound is Stopped” and as soon as the user click on play button the text is “playing”[/color]  
[color=black][/color]  
[color=black]but this code seems to be not working?[/color]  
[color=black][/color]  
[color=black]wats wrong with it?[/color]  
[color=black][/color]  
[color=black]help me[/color]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 22, 2004, 9:16am UTC](https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013/2 "2004-09-22T09:16:29Z")

</div>

I see two problems with the code:

First you set the sound to stop(), then you check in the if statement if it has stopped. This way it will always be true since this code will only run if the button is clicked, so you never get to the ‘else’ statement.

Another thing is that \_root.dl = “Sound is Stopped”; doesn’t seem correct. If ‘dl’ is a dynamic textfield, you should use the .text property to assign the new text like:  
\_root.dl.text = “Sound is Stopped”;

So I’d write:

on (press) (  
\_root.mySlider.mySound.stop();  
\_root.dl.text = “Sound is Stopped”;  
)

Hope that helps 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 23, 2004, 6:08am UTC](https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013/3 "2004-09-23T06:08:14Z")

</div>

Redsox this is the error

**Error** Scene=Scene 1, layer=Stop, frame=1:Line 1: ‘{’ expected  
on (press) (

**Error** Scene=Scene 1, layer=Stop, frame=1:Line 2: ‘)’ expected  
\_root.mySlider.mySound.stop();

**Error** Scene=Scene 1, layer=Stop, frame=1:Line 4: Unexpected ‘)’ encountered  
)

Total ActionScript Errors: 3 Reported Errors: 3

help

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 23, 2004, 6:17am UTC](https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013/4 "2004-09-23T06:17:22Z")

</div>

Two of your errors are because you used ( & ) instead of { & }.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 23, 2004, 6:47am UTC](https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013/5 "2004-09-23T06:47:51Z")

</div>

errors disappeared but the code is yet not working…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2004, 6:23am UTC](https://forum.kirupa.com/t/this-code-seems-to-be-not-working/65013/6 "2004-09-28T06:23:28Z")

</div>

it looks like the else statement is outside the if statement, in this case, it renders the else statement as the next viable statement, (actionscript doesn’t see the else as pertaining to the if, so it perceives the value as default, ie, true, and executes the text change.)
