16 Replies Latest reply on Jul 12, 2007 8:39 AM by Damon Edwards

    draggable button

    ski760
      I have a moviclip with a button inside of it, and I want the movie clip to be draggable. The button I have inside works fine, but as soon as I add the startdrag action to the movie clip the button stops working. I'm trying to build an OS style interface similar to link I provided below. Can some one help me learn how to go about this?

      (click skip to skip video)
      http://www.hp.com/personalagain/us/en/shaun_white.html
        • 1. Re: draggable button
          takennickname Level 1
          Likely, the start drag is grabbing the MC symbol at a position that your button can't be clicked. Make sure the button's "hit" area is large enough for wherever they might initiatate the startdrag.

          Also, you might have to modify your button code to identify the main timeline, if necessary, by using root., or level0., it depends on what you're button is attempting to do.

          hth,
          K.
          • 2. Re: draggable button
            ski760 Level 1
            The button works fine until I add the startDrag to the movie clip. The buttons does what it's suppose to do, but once I add the start drag to the movieClip the buttons disables. I have I good size hit stat for it also. Check the hp link I posted I tell me hoe you would go about putting the window together.
            • 3. Re: draggable button
              takennickname Level 1
              This might be your solution, as I noticed a single-click drag of the clip, but a double-click to initiatate the button. View this tutorial, it might be your solution.
              http://www.spoono.com/flash/tutorials/tutorial.php?id=19

              K.
              • 4. Re: draggable button
                ski760 Level 1
                Got things to work you were of great help. Thanks a lot!
                • 5. Re: draggable button
                  Nickels55 Level 2
                  Very cool site Ski760 - nice work!
                  • 6. Re: draggable button
                    takennickname Level 1
                    Anytime... glad to help.

                    -Kalen
                    • 7. Re: draggable button
                      lukeduke7
                      I have been looking for an example thread like this and it has been a great help. I have accomplished double clicking a button and haveing my draggable movie show. What I can't figure out is how to close the draggable movie by using a button on the movie. Right now I have to double click the button that opens it.

                      Question: How could I close a "pop-up" draggable movie with a close button like the one in the Shawn White website?

                      Thanks in advance!!
                      • 8. Re: draggable button
                        lukeduke7 Level 1
                        Here is the code I have been using if it can be any help at all.

                        Am I looking at a pretty extensive actionscript to accomplish what I am looking to do?

                        Appreciate any help offered. Thanks Again.

                        //DOUBLE CLICK TO SHOW CONTENT
                        //set initial variables
                        click = false;
                        //function for the button press
                        button_btn.onPress = function() {
                        //if this is the first click
                        if (!click) {
                        timer = getTimer()/1000;
                        _root.click = true;
                        }
                        else {
                        timer2 = getTimer()/1000;
                        //if it is a double click
                        if ((timer2-timer)<.25) {
                        //toggle the box mc on and off
                        if (_root.box_mc._visible==false) {
                        _root.box_mc._visible = true;
                        } else {
                        _root.box_mc._visible = false;
                        }
                        } else {
                        timer = getTimer()/1000;
                        _root.click = true;
                        }
                        }
                        };

                        //DRAGGING CONTENT
                        //border variables
                        left = 0;
                        top = 0;
                        right = Stage.width;
                        bottom = Stage.height;
                        //drag the mask
                        _root.box_mc.onPress = function() {
                        startDrag(this);
                        }
                        _root.box_mc.onRelease = function() {
                        stopDrag();
                        }
                        stop();
                        • 9. Re: draggable button
                          Damon Edwards Level 3
                          inside box_mc make a button and use onRelease to set the _parent.box_mc._visible = false;
                          • 10. Re: draggable button
                            lukeduke7 Level 1
                            Thanks for the input. I am finding out this doesn't work when the close button is inside the box_mc. When I take it out and put it on the main stage it works. It seems to not recognize it as a button or something. When I do have it placed in the box_mc, away from it, it uses that as a drag point. The cursor turns into a hand, but i am not sure if it is because it recognizes it as a drag point first and not a button. Does that make any sense. I will keep messing with it and I really appreciate your help. Seems like it should be simple, which i'm sure it is, maybe I have one small thing wrong.

                            Thanks Again!
                            Luke
                            • 11. Re: draggable button
                              Damon Edwards Level 3
                              hitTest() i believe will fix that
                              • 12. Re: draggable button
                                lukeduke7 Level 1
                                Thanks again for the quick response. I am working on how to use this hitTest(). I went to the reference window in flash and its discusses it features. As of now I haven't gotten it to work. I am determined to get this to work, and this I believe is on the right track.

                                Your help is always valued.
                                Luke
                                • 13. Re: draggable button
                                  lukeduke7 Level 1
                                  After many attempts, no such luck. I will paste in actionscript forum. Thanks for you help!
                                  • 14. Re: draggable button
                                    Damon Edwards Level 3
                                    i dont see what the problem is. give the button you created inside your box_mc an instance name of my_btn. then attatch this code to replace your original code on the main timline
                                    • 15. Re: draggable button
                                      lukeduke7 Level 1
                                      This works except the entire draggable movie clip is the click able area. Click any where on the draggable content and it closes. You can drag it but uppon mouse up, it disappears.

                                      Sorry for the invonvience, may be a bit out of my league here, but that is why i'm here.

                                      THANKS FOR ALL YOUR HELP!

                                      Luke
                                      • 16. Re: draggable button
                                        Damon Edwards Level 3
                                        it would be much easier to put the dragable button underneath, then you can drag everywhere but where the button is.. just a suggestion..