5 Replies Latest reply on Feb 27, 2007 11:06 PM by nchavie

    Flash MP3 Player

    nchavie
      I have created a very basic MP3 player in flash that works just fine. However when I place all of the buttons and movie clips in to another movie clip (in another .fla file) the volume slider doesn't work. Everything else works just fine except the volume slider. As soon as you click it the slide bar jumps to the upper left corner of the screen. I am certain it is a really simple fix but for the life of me I can't figure it out.

      Here is the action script for the mp3 player:

      [code]
      var myAudio_sound:Sound = new Sound();
      myAudio_sound.attachSound("sound_ebonicsID");

      playbtn.onRelease = function() {
      myAudio_sound.start(0,1);
      };

      stopbtn.onRelease = function() {
      myAudio_sound.stop();
      };

      vol_up_btn.onRelease = function() {
      myAudio_sound.setVolume(100);
      };
      vol_down_btn.onRelease = function() {
      myAudio_sound.setVolume(0);
      };

      l_spk_btn.onRelease = function() {
      myAudio_sound.setPan(-100);
      };

      r_spk_btn.onRelease = function() {
      myAudio_sound.setPan(100);
      };

      c_spk_btn.onRelease = function() {
      myAudio_sound.setPan(0);
      };

      slider_mc.onPress = function() {
      this.startDrag(false,
      _root.groove_mc._x,
      _root.groove_mc._y - 100,
      _root.groove_mc._x,
      _root.groove_mc._y);
      };
      slider_mc.onRelease = function() {
      stopDrag();
      };

      slider_mc.onMouseMove = function() {
      var myPoint:Object = new Object();
      myPoint.x = this._x;
      myPoint.y = this._y;
      _root.groove_mc.globalToLocal(myPoint);
      myAudio_sound.setVolume(-myPoint.y);
      };
      [/code]

      Any ideas?

      Thanks.
        • 1. Re: Flash MP3 Player
          SymTsb Level 2
          it actually simple as pie. it's the startDrag() call. don't use _root to call this. Go back to the mp3 player file and replace _root with this._parent or whatever the relative path turns out to be until it works without the _root. then go back to the file where you are trying to load the mp3 player into and it should work perfectly.
          • 2. Re: Flash MP3 Player
            nchavie Level 1
            Thanks for the help!

            I am not that good with flash...what do you mean by relative path?

            Also I change the _root to _parent and that didn't change anything.

            In case this helps, in the time line of the movie clip in the new .fla file that I am trying to add the MP3 player to I have used a blank key frame to add all of the MP3's buttons, movie clips, and coding.

            Thanks again for the help
            • 3. Re: Flash MP3 Player
              nchavie Level 1
              bump
              • 4. Re: Flash MP3 Player
                SymTsb Level 2
                say you have a movie clip on the main timeline called player. inside player is another movie clip called stop_btn

                your movie heirarchy would be like this

                main
                player
                stop_btn

                player can access the main timeline one of two ways.

                absolute path _root
                relative this._parent

                stop_btn can access the main timeline one of two ways. absolute path or relative path...

                absolute path would be _root
                relative path would be this._parent._parent

                Determine the heirarchy of your player from within it's own swf file first. Map it out on paper if necessary. After you've mapped it out, build the relative path back to it's main timeline. Once you've done that, export the movie again and load it into the other movie. The player's volume control should be working again.
                • 5. Re: Flash MP3 Player
                  nchavie Level 1
                  I just want to let you know that you are my hero...

                  That worked perfectly. Thank you so much for taking the time to explain that.