Thank you for all of this; it is very helpful.
I have series of 6 buttons I created, each of them load a different movie clip. I need to have the music from the slideshow NOT continue to play when a new movie clip is selected.
I have the following code.
Frame 1:
--------------------------------------------------------------------
SlideshowMusic = new Sound(this);
SlideshowMusic.attachSound("MastersThisHall");
stop();
--------------------------------------------------------------------
Frame 120 (attached to the Slideshow movie clip object):
--------------------------------------------------------------------
onClipEvent (load) {
SlideshowMusic.play();
}
--------------------------------------------------------------------
The "Mute" Button:
--------------------------------------------------------------------
on (release) {
SlideshowMusic.setVolume(0);
}
--------------------------------------------------------------------
The "Resume Sound" Button:
--------------------------------------------------------------------
on (release) {
SlideshowMusic.setVolume(100);
}
--------------------------------------------------------------------
And the "Pause" Button:
--------------------------------------------------------------------
on (release)
{
if (SlideshowMusic.position < SlideshowMusic.duration)
{
SlideshowMusic.start(SlideshowMusic.position / 1000);
}
}
--------------------------------------------------------------------
It is loading and working perfectly. However, I have two more questions:
1. How do I make the the sound automatically stop when a new movie clip is played?
2. How do I change the "pause" symbol to the "play" symbol when the "Pause" button is pressed?
remove all sound from your objects (movieclips and buttons). assign your buttons and movieclips, that execute code, instance names (in the properties panel).
for example, name your "Mute" button (mute_btn), your "Resume Sound" button (unmute_btn), your "Pause" button (pause_btn) and create a play button (play_btn).
also, assign your 6 buttons that direct your timeline to different frames instance names (eg, mc0_btn, mc1_btn, mc2_btn,.., mc5_btn) and put those frames in an array:
SlideshowMusic = new Sound(this);
SlideshowMusic.attachSound("MastersThisHall");
stop();
play_btn._visible=false;
var gotoA:Array=[120,220,100,50,300,72];
for(var i:Number=0;i<gotoA.length;i++){
this["mc"+i+"_btn"].ivar=i;
this["mc"+i+"_btn".onRelease=function(){ //<-this encodes all 6 buttons
this.gotoAndStop(gotoA[this.ivar]);
pause_btn.onRelease();
}
}
mute_btn.onRelease=function(){
SlideshowMusic.setVolume(0);
}
unmute_btn.onRelease=function{
SlideshowMusic.setVolume(100);
}
pause_btn.onRelease=function(){
SlideshowMusic.stop();
this._visible=false;
play_btn._visible=true;
}
play_btn.onRelease=function(){
if (SlideshowMusic.position < SlideshowMusic.duration)
{
SlideshowMusic.start(SlideshowMusic.position / 1000);
}
this._visible=false;
pause_btn._visible=true;
}