Music Buttons

Creator:
jeandaquil

The music doesnt start automaticly. Find a short but simple loopable .wav file. .wav is recommended but you can use .MP3 or Newgrounds are great places to find music Open flash (obviously)

Make 3 Keyframes if you are going to put a small preloader useless)

Make 2 keyframes if you wont use a preloader

In frame 2 (It's Frame 1 for those that didnt included a preloader.)

Make a button that says PLAY Right click on frame 2 (It's Frame 1 for those that didnt included a preloader.) and select ACTION in the action window, put this exact code:

stop();

Now right click on frame 3 (It's Frame 2 for those that didnt included a preloader.) and select ACTION again Put this exact BIG chunk of code

stop(); 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) ); _global.Behaviors.Sound.music = new Sound(this._parent.BS_music); } else { this.createEmptyMovieClip('_music_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) ); _global.Behaviors.Sound.music = new Sound(this.BS_music); } _global.Behaviors.Sound.music.attachSound(\"music\"); if (true) { _global.Behaviors.Sound.music.start(0,50); }

Were it say

.Sound.music.start(0,50);

50 is the number of time the music will loop In the same frame, put a button that say STOP

Now right-click on the new STOP button and choose ACTION Put that exact code in:

on (release) { gotoAndStop(2); _global.Behaviors.Sound.music.stop(); }

Do the same for the PLAY button but this time, put this code in:

on (release) { nextFrame(); }

still there? ok, now the easy part Import your song file-import Go in the Library and right click on your song, select LINKAGE check EXPORT FOR ACTIONSCRIPT you should have 2 checkbox checked In the IDENTIFIER field, type music Thats all! press ok, test your button and it should work fine!

Description:
This tutorial will explain step by step how to make a semi-advanced music button for new flash artists.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options