all groups > flash (macromedia) > february 2006 >
You're in the

flash (macromedia)

group:

Need help on Music on/off button



Need help on Music on/off button SEPHlROTH
2/19/2006 10:01:49 PM
flash (macromedia): Hi I'm still a newbie so plaese dont get mad cus this sample question may have
been asked many times already but please help.

I'm putting music in my flash now and its on a new layer, I can make a button
to tell it stop or play, but it has to be 2 buttons, how can I make a pause
button so if I press it once it will stop on that frame and if I press it again
it will play from that frame again?:confused; I'm using flash MX.:confused;
Re: Need help on Music on/off button SEPHlROTH
2/19/2006 10:41:07 PM
Sorry for bumping but I also forgot to ask how to make a mute function, u know
like the music is still playing at the background but its muted until a button
is pressed. also is it possible to mute all sound in the movie including button
sound effect?
Re: Need help on Music on/off button albee
2/19/2006 11:33:04 PM
If you want to create something that acts like a player, you need to use the
Sound object. First, import your sound (Flash accepts MP3 or WAV files). Then,
in your library, right-click on the icon representing the sound that you
imported, and select "Linkage...". Check the "Export for ActionScript" and
"Export in first frame" boxes and enter a name in the Identifier box (for this
example we'll use "song_id" (don't put quotes around it here)).

Next, on the first frame of the main timeline enter this code:
my_sound = new Sound();
my_sound.attachSound("song_id"); // DO put quotes around the identifier name
here!!
var pausePoint = 0;
var soundValue = 100;

Next on your play button, add this code:
on (release) {
if (_root.soundValue == 100) {
my_sound.start(_root.pausePoint / 1000);
}
}

Then, on your pause button, add this code:
on (release) {
if (_root.soundValue == 100) {
my_sound.stop();
_root.pausePoint = my_sound.position;
}
}

This should give you a basic start and stop player... For muting, put this
code on the mute button:
on (release) {
if (_root.soundValue == 100) {
_root.soundValue = 0; // if you want to reduce the sound but not completely
mute it, make this a number between 0 and 100
} else {
_root.soundValue = 100;
}
my_sound.setVolume(soundValue);
}


Good luck,

Albee
Re: Need help on Music on/off button SEPHlROTH
2/20/2006 1:26:27 AM
Thanks for the code man, I'll try it later:):):):):)

AddThis Social Bookmark Button