First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: me | Website:
In this tutorial I will explain how to do an advanced music button in flash MX 2004 and MX,

insert 3 frame
  • frame for the preloader
  • frame for the music on button
  • frame for the music off button
Put a preloader in the first frame (if you dont want a preloader, get rid on the first frame)

then go in the second frame and put a button that say MUSIC OFF

Go in the third frame and put a button that say MUSIC ON.

Import your song (i recommend a small loopable beat)
Now go in the library, right-click on your song and choose Linkage...

check the EXPORT FOR ACTIONSCRIPT box (it will automaticaly check the last box too)

in the identifier text-field, type music.
leave everything else blank.
press OK

right-click on the second frame (or the first if you didnt included a preloader)
and select ACTION, put this code in


if(_global.Behaviors == null)_global.Behaviors = {};
if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
if(typeof this.createEmptyMovieClip == 'undefined'){
this._parent.createEmptyMovieClip('BS_music',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) ); = new Sound(this._parent.BS_music);
} else {
this.createEmptyMovieClip('_music_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) ); = new Sound(this.BS_music);
if (true) {,1);

in the last line, you see music.start(0,1);
the "1" is the number of time the music will loop, so change it to the number you want, you CANT make the music loop infinite....sorry.

now right-click on your MUSIC OFF button and select ACTION. Put this code in

on (release) {

if you didnt included a preloader, change the gotoAndStop(3); for gotoAndStop(2);

now go in the last frame and go in the action window for the MUSIC ON button and type in

on (release) {

now test your movie, and it should work!

if you want to replace a song, delete the old one and upload a new one, do the linkage trick again

» Level Basic

Added: 2003-11-10
Rating: 6.91 Votes: 66
(10 being the highest)
» Author
my first tutorial at flashkit
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.