I have followed the Music Player and Volume Controller tutorials and as a result, can now play, stop and adjust the volume of a music file that is defined in the code. My apologies in advance if the questions below have been answered in the past.
However, I have searched the forums and can’t seem to find anything directly answering the two following questions:
i) What code would be required (I would assume code would only be required for the button used for pausing) for a button to pause the music playing when pressed?
ii) What code would be required (I would assume code would only be required for the button used for muting) for a button to mute the music playing when pressed?
I’m fine thanks. I haven’t had the opportunity to test this out yet because I have been trying to help SBV in another thread. Give me a few minutes and I will see what I can come up with :).
Well, it’s certainly not trivial. Following the soundbar tutorials, you end up with a soundbar with which you can Play, Stop and Adjust the volume of a piece of music.
The Play button has this code applied to it:
[AS]on (release) {
if (_root.mySlider.complete == 1) {
_root.mySlider.mySound.start(0, 99);
}
}[/AS]
The Stop button has this code applied to it:
[AS]on (release) {
_root.mySlider.mySound.stop();
}[/AS]
But the majority of the code resides in the slider which you use to adjust the volume.
If you follow what kax said, I think you need to do two separate things to get the Pause and Mute functions working. I may not be able to get it to work but I will do my best, give me a few more minutes please :).
Note that I’m relatively new to Flash (less than a week), so I am hardly a coding expert.
No luck, sorry. I can roughly see what you need to do but I don’t know exactly how to do it. Hopefully somebody will be able to clarify this for us :).
No problems. Only next time, I would like to be able to solve the problem as well :).
It’s really frustrating because I can see what you need to change in the code to suit your file but I can’t work out exactly where the code would need to go :-.
Hi Kax, I really want to show you my fla file, but the file is too big to send on this sever.
but if you really kind enough to help me, I have created a fla file that have Play, Pause, Stop and Mute buttons in it, there is no code in it, because I assume that it would be easier for you to work on, as I may make a lot of mistakes and you have to modify them. it will be gratefull if you can make it work.
My apologies first if this is not a good way to ask
thank you
Haha go figure - neither of those work. The new play ActionScript works because it doesn’t actually change the function it just enhances it… but the ActionScript for pause and mute doesn’t work.
I think the mute could be done by using setVolume(0) when the user clicks the mute button but there is a problem with that in this case because the volume slider has mySound coded ‘inside’ it as such.
I looked in the help file of Flash MX and it doesn’t have .mute or .pause in the commands concerning sound :(. Perhaps you have to code both functions?
… either way, this has helped me improve my coding knowledge. Shame it doesn’t work though ;).