[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]
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
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
Two of your errors are because you used ( & ) instead of { & }.
errors disappeared but the code is yet not working…
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.)