Greetings again! Just wanted to know… I’m using multiple background music in the cartoon that I’m making, but I don’t want to go into all the trouble of actually editting the mp3 using another program. So, how do we make it in flash so that when a certain frame is reached, the specified background music will stop or start, and as well as when a certain button is pressed, the music will stop or start.
the trick to controlling your sounds with precision is to use ActionScript. Before continuing with an explanation on how this is done, you must make sure that you export your sound from the library. To do this, right-click on the sound you want exported from the library and click Linkage…. When a box appears, check the Export for ActionScript box, and enter a relevant name in the Identifier text box. Once that’s done, you’re ready for some ActionScript
1. Stopping a sound at a particular frame
Assuming your cartoon is inside a movie clip with the instance name cartoon (and is placed on the _root level) and that you exported your sound as track1, attach the following code to your movie clip:
onClipEvent(load) {
this.soundTrack = new Sound();
this.soundTrack.attachSound("track1");
this.soundTrack.start(0, ***number of loops***);
this.soundInit = true;
}
onClipEvent(enterFrame) {
if(this._currentframe == ***frame to stop sound***) {
this.soundTrack.stop("track1");
}
}
That should do it.
2. Starting and stopping sound with a button
Make a button and attach the following code to it (I am assuming that you want to start and stop the sound in your movie clip cartoon):