• home
  • forum
  • my
  • kt
  • download
  • Music button in MX and MX 2004

    Author: 2007-06-10 10:06:01 From:

    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

    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,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

    CODE
    on (release) {
    gotoAndStop(3);

    _global.Behaviors.Sound.music.stop();
    }


    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

    CODE
    on (release) {
    prevFrame();
    }


    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.75 Votes: 60
    Hits: 1489
    » Author
    my first tutorial at flashkit
    » Download
    Download the files used in this tutorial.
    Download (0 kb)

    discuss this topic to forum

    relation tutorial

    No information

    Category

      3D (36)
      Math Physics (18)
      3rd Party (10)
      Navigation (70)
      Actionscripting (228)
      Optimization (17)
      Animation (166)
      Projector (11)
      Audio (54)
      Special Effects (170)
      Backend (26)
      Text Effects (92)
      Drawing (34)
      Tips and Techniques (58)
      Dynamic Content (38)
      Tricks (8)
      Games (114)
      Utilities (24)
      Getting Started (99)
      Video (59)
      Interactivity (48)
      Web Design (37)

    New

    Hot