5 Replies Latest reply on Jun 24, 2009 2:20 PM by Reuben D

    Drag function disabling button actions within movieclip

    Reuben D

      I'm building an interactive map and i've run into a problem. The map is draggable and I have a start and stop drag function running as well as an onEnterFrame function which restricts how far you can drag the map. The map is displayed inside of a masked area. On the map is many locations which when rolled over should pop up a little dialogue box with contact info. My problem is that it only works when i've disabled the drag functions. When the drag functions are running the buttons inside the map movie clip all stop working. How can i get around this?

       

      Drag function:
      // Start Dragging sequence
      map_mc.onPress = function() {
          this.startDrag();
      };

      // Stop Dragging sequence
      map_mc.onRelease = function() {
          this.stopDrag();
      };

      onEnterFrame = function() {
      //Restricts player to stage

       

      //
      if(mc_map._x <= -1400) {
        mc_map._x = -1400;
      }

       

      //Restricts Bottom
      if(mc_map._y <= -400) {
        mc_map._y = -400;
      }

       

      //Restricts Left
      if(mc_map._x >= 50) {
        mc_map._x = 50;
      }

       

      //Restricts Top
      if(mc_map._y >= 50) {
        mc_map._y = 50;
      }
      }

       

      Sample button function:
      //Distributors
      santafespringsDI_btn.onRelease = function() {
      distributorLabels_mc.gotoAndStop(11);
      distributorLabels_mc._x = _root._xmouse + 10;
      distributorLabels_mc._y = _root._xmouse - 80;
      }
      santafespringsDI_btn.onRollOver = function() {
      distributorLabels_mc.gotoAndStop(11);
      distributorLabels_mc._x = _root._xmouse + 10;
      distributorLabels_mc._y = _root._xmouse - 80;
      }
      close_btn.onRelease = function() {
      distributorLabels_mc.gotoAndStop(1);
      }

        • 1. Re: Drag function disabling button actions within movieclip
          Ned Murphy Adobe Community Professional & MVP

          You can use the startDrag function to define the limits of dragging rather than using an enterFrame function.  Just look it up in the help docs and the argument options will be explained.

           

          For dragging the map, if your various buttons are inside the map movieclip, then you need to make the map background carry the code and set it to drag the _parent.... startDrag(this._parent).  That way, your map with the items in it are dragged together, but the buttons inside are on top of the item with the drag code assigned to it.

          1 person found this helpful
          • 2. Re: Drag function disabling button actions within movieclip
            Reuben D Level 1

            Hi Ned,

            I'm having trouble with the hierarchy of everything now. I've used the startDrag() function for the boundaries now (thanks for that). I've moved the code to do the dragging inside of the map_mc and placed it on the background. I've adjusted the code for it to drag the map_mc from within the movieclip itself. The buttons inside the movieclip are still not working. I'll keep playing with it and i know i'm extremely close.

            Reading above it sounds as though you want me to try and drag the map and background from within the movie clip. This may not work because of all the location buttons i have on the map. They need to stay synced with the map. If the map moves, they need to move too.

            Any ideas?

            • 3. Re: Drag function disabling button actions within movieclip
              Ned Murphy Adobe Community Professional & MVP

              If you do what I say, you will be dragging the movie that contains everything  [  use startDrag(this._parent) on the background ] , so everything in the movie will travel with it.  I'm going to post a link to an example (this same issue came up recently so I created one).

               

              example: http://www.nedwebs.com/Flash/dragMap.fla

              • 4. Re: Drag function disabling button actions within movieclip
                Reuben D Level 1

                I got it working, but i managed to break it again. I think this is why i was having difficulty with your suggestions earlier. I added a bit more to my code and broke it.

                 

                I have a movie clip full of captions that i assign to each location. the button will make the movie clip jump to a certain frame revealing the appropriate caption for the appropriate location and then on rollout go back to the first frame of the movie clip to hide it again. Adding this functionality in stopped the dragging and I'm wondering why it did and how i get around it?

                 

                The button code i added to activate the caption movie clip was this:

                 


                btn.onRollOver = function() {
                    captions_mc.gotoAndStop(11);

                    captions_mc._x = _root._xmouse + 10;
                    captions_mc._y = _root._xmouse - 80;
                }

                 

                btn.onRollOut = function() {
                    captions_mc.gotoAndStop(1);
                }

                • 5. Re: Drag function disabling button actions within movieclip
                  Reuben D Level 1

                  Nevermind i think it was just caching.