11 Replies Latest reply on Dec 21, 2006 12:22 PM by dtedone1

    mouse attach

    dtedone1 Level 1
      I would like the navigation on my site www.1dt.biz to go to the cursor when it is over the 'screen' - at the moment the 'screen' area is a button with a drag and stop drag behavior attached - I need the navigation to return from wherever it is to the cursor when the cursor is over the 'screen' area. - the navigation is in a movie clip
        • 1. Re: mouse attach
          kglad Adobe Community Professional & MVP
          you can use Mouse.hide() and Mouse.show() to hide and reveal the user's cursor when it suits your needs (and the _visible property of your custom cursor to reveal and hide it when it suits your needs).
          • 2. Re: mouse attach
            dtedone1 Level 1
            I don't want to hide the mouse - I want the mouse to attract the navigation movie clip to it when it is over the screen button area
            • 3. Re: mouse attach
              kglad Adobe Community Professional & MVP
              then start a loop that updates navigation's _x and _y properites.

              if you want the navigation movieclip to converge on those _xmouse and _ymouse properties you can use an easing equation. if you want navigation to move directly under the pointer, assign navigation's _x and _y properties to be the same as _xmouse and _ymouse.
              • 4. mouse attach
                dtedone1 Level 1
                Many thanks for that - a couple of questions, as I know almost nothing about writing my own scripts, but am very willing to learn, how would I go about doing what you have kindly suggested, 2nd question, because of the need to be able to press the buttons on the navigation panel once it has been dragged off the screen area, would I use an onclip event attached to the screen button ?

                Just had a thought - could I put additional code in the button 'on rollover - drag' behavior to align the movieclip with the mouse ?
                • 5. Re: mouse attach
                  kglad Adobe Community Professional & MVP
                  which of the two suggestions, converging or moving directly?

                  but better yet, just exactly what are you trying to do? if you have a navigation menu, do you want it to be movable so user's can position it wherever they want? or do you really want it to move towards the cursor (which would be very annoying unless that movement could be stopped by the user)?
                  • 6. mouse attach
                    dtedone1 Level 1
                    Thanks for coming back on this - here goes:- I would like the navigation_mc to be attached to the mouse x & y coordinates when it is a specific area only - once the navigation_mc is dragged out of that area the navigation_mc stops & the navigation buttons can be used - at the moment I am using a rollover & drag behavior assigned to a button to achieve part of this - see www.1dt.biz - but the effect is a little crud to say the least, if I could somehow add assign navigation_mc _x and _y properties to be the same as _xmouse and _ymouse as a button behavior it would solve my problem - I hope, think, pray, but don't really know. (please note: the button is quite large - about one 3rd. of the screen size.)
                    • 7. Re: mouse attach
                      kglad Adobe Community Professional & MVP
                      you can use the following which will not interfere with your button handlers. use your own conditions to terminate the movieclips movement:

                      • 8. Re: mouse attach
                        dtedone1 Level 1
                        Many thanks Kglad - I will give it a go asap
                        • 9. Re: mouse attach
                          kglad Adobe Community Professional & MVP
                          you're welcome.
                          • 10. Re: mouse attach
                            dtedone1 Level 1
                            Brilliant ! works well - I put it on the button & pasted "delete this.onMouseMove." into the rollOut behavior - is that the best way to do it ?
                            the movement of the movieclip is a little jerky but the control is so much better - I will mess around and try to smooth out the movement - this is how I pasted in the code
                            Thanks again & Merry Christmas

                            (rollOut) {
                            //Stop Dragging Movieclip Behavior
                            stopDrag();
                            //End Behavior
                            delete this.onMouseMove;


                            }
                            on (rollOver) {
                            //Start Dragging Movieclip Behavior
                            startDrag(this.menuholder_mc);
                            //End Behavior
                            this.onMouseMove = function() {
                            menuholder_mc._x = this._xmouse;
                            menuholder_mc._y = this._ymouse;
                            if (menuholder_mc._x<0 && menuholder_mc._y<0) { // <- use your own constraints
                            delete this.onMouseMove;
                            }
                            updateAfterEvent()
                            };
                            • 11. Re: mouse attach
                              dtedone1 Level 1
                              Brilliant ! works well - I put it on the button & pasted "delete this.onMouseMove." into the rollOut behavior - is that the best way to do it ?
                              the movement of the movieclip is a little jerky but the control is so much better - I will mess around and try to smooth out the movement - this is how I pasted in the code
                              Thanks again & Merry Christmas

                              (rollOut) {
                              //Stop Dragging Movieclip Behavior
                              stopDrag();
                              //End Behavior
                              delete this.onMouseMove;


                              }
                              on (rollOver) {
                              //Start Dragging Movieclip Behavior
                              startDrag(this.menuholder_mc);
                              //End Behavior
                              this.onMouseMove = function() {
                              menuholder_mc._x = this._xmouse;
                              menuholder_mc._y = this._ymouse;
                              if (menuholder_mc._x<0 && menuholder_mc._y<0) { // <- use your own constraints
                              delete this.onMouseMove;
                              }
                              updateAfterEvent()
                              };