Well I can tell you right off the bat that you can place another ‘stop all sounds’ before the ‘play’ action on the play button. That will clear anything that’s running before the sound begins playing.
The button, actually remaining down while it’s playing will be a little more tricky I suppose.
What I would do, if I were you, would be to start right out controling more movie clips. It’s good experience. You’re going to read this and say,… omg. that’s too complex. But really it’s not. Take it one step at a time. If one step stumps you, ask… I’ll clarify.
Create a square of fill. Select it and hit F8. Select button and hit “ok”. Double click the button you just created to bring up it’s timeline. Select frame one and drag it to frame four. The first three frames should be completely empty.
Go back to the main timeline. You’ll see a pale blue silouette of the button you just made. This is an invisible button. It has no image associated with it at all, and does not show up on the stage in production. It does however have a hit spot so it can be clicked on.
Transfer the code from your current button to this invisible button. Just select it, copy/cut, select the invis button then the action panel, then paste.
Select your origional button. In the “Instance” panel, change it from a button to a movie clip. give it an instance name in this box. do not use “play” or “stop” as these words may be used by Flash for something. I’ll use “ply” for the play button and “stp” for the stop button. With the instance names in place and both set as movie clips you can now call to them to make them play, just like you did with the sound movie clip.
There is a problem. The movie clips start playing right off the bat. You could go into each and set a stop() action on the first frame but you could also attach code to the outside of the movie clip which is easier.
onClipEvent(load){
this.stop();
}
simply stops the clip as soon as it loads up on the stage.
If you’re unfamiliar with attaching code to movie clips, it’s really just the same as attaching code to buttons.
Then all you need to do is add to your button, some code.
on(release){
stopAllSounds();
mySoundClip.play();
//mySoundClip is a generic name.
trip=false;
//sets trip to keep play button down.
ply.gotoAndStop(3);
}
on(rollOver){
trip=true;
//sets trip to allow play button to raise.
ply.gotoAndStop(2);
}
on(rollOut){
if(trip){
ply.gotoAndStop(1);
}
}
on(press){
ply.gotoAndStop(3);
}
a second invisible button can be placed for the ‘stp’ clip and have the following code
on(release){
stopAllSounds();
stp.gotoAndStop(2);
}
on(rollOver){
stp.gotoAndStop(2);
}
on(rollOut){
stp.gotoAndStop(1);
}
on(press){
stp.gotoAndStop(3);
}
The last thing you want to do is set some code on the last frame of the sound containing movie clip. That would be
stopAllSounds();
//it’s redundant… but sometimes redundancy is good
_parent.ply.gotoAndStop(1);
sends the play clip back to frame 1
gotoAndStop(1);
//send the sound clip’s playhead back to frame 1.
Well… this all looks a lot more complex than I wanted it to be. It really is quite easy to do once you get the hang of it. Try it out… like I said. I’ll answer any questions that come up.