7 Replies Latest reply on Jun 7, 2006 12:13 PM by Rothrock

    mouse and circle

    Level 7
      Hello,

      I have a circle and inside i have a ball
      I would with my mouse dont get out the circle when I move

      could you tell me how can i do please
      I hope you undertand me

      thank you


        • 1. Re: mouse and circle
          Rothrock Level 5
          moose and squirrel?

          You can't – at least not as you have presented it. The mouse sits on the user's desk and Flash can't "reach out and grab" their hand.

          It is possible to restrict the ball to only being dragged wihin the circle. Is that what you want?
          • 2. Re: mouse and circle
            Level 7
            Hello,

            It's what I want
            If you can give me the script THANK YOU

            "Rothrock" <webforumsuser@macromedia.com> a �crit dans le message de news:
            e64kv9$ott$1@forums.macromedia.com...
            > moose and squirrel?
            >
            > You can't ? at least not as you have presented it. The mouse sits on the
            > user's desk and Flash can't "reach out and grab" their hand.
            >
            > It is possible to restrict the ball to only being dragged wihin the
            > circle. Is
            > that what you want?
            >


            • 3. Re: mouse and circle
              Level 7
              please do you have a solution ?
              thank you

              "Dave" <frsingles@ifrance.com> a �crit dans le message de news:
              e64lcn$pfj$1@forums.macromedia.com...
              > Hello,
              >
              > It's what I want
              > If you can give me the script THANK YOU
              >
              > "Rothrock" <webforumsuser@macromedia.com> a �crit dans le message de news:
              > e64kv9$ott$1@forums.macromedia.com...
              >> moose and squirrel?
              >>
              >> You can't ? at least not as you have presented it. The mouse sits on the
              >> user's desk and Flash can't "reach out and grab" their hand.
              >>
              >> It is possible to restrict the ball to only being dragged wihin the
              >> circle. Is
              >> that what you want?
              >>
              >
              >


              • 4. Re: mouse and circle
                Rothrock Level 5
                Please do you have some patience? I do have a day job and can't answer everything immediately. In the two hours since your first response what have you done to answer your question? Remember that everybody here is a volunteer and nobody is paid or required to answer anything.

                That being said. Create a circle movieclip put it on your stage with the name myCircle. Make a little ball movieclip and put it on the stage with the name ball. Then put this code on the frame. There you go!
                • 5. Re: mouse and circle
                  Rothrock Level 5
                  I forgot to mention that the myCircle movieclip should have the registration point at the center of the circle. Also I don't know what I was thinking. I like this version of the code much better. It is much smoother.
                  • 6. Re: mouse and circle
                    Level 7
                    Hello

                    Thank you it's good solution
                    I would like to do with this two eyes and I would like to move the pupul
                    with mouse
                    I canto do that
                    please could you help me ?

                    "Rothrock" <webforumsuser@macromedia.com> a �crit dans le message de news:
                    e65578$f29$1@forums.macromedia.com...
                    >I forgot to mention that the myCircle movieclip should have the
                    >registration
                    > point at the center of the circle. Also I don't know what I was thinking.
                    > I
                    > like this version of the code much better. It is much smoother.
                    >
                    > ball.onPress = function() {
                    > var cX = myCircle._x;
                    > var cY = myCircle._y;
                    > var radius = myCircle._width/2;
                    > this.onMouseMove = function() {
                    > var curX = myCircle._xmouse;
                    > var curY = myCircle._ymouse;
                    > var dist = Math.sqrt(curX*curX+curY*curY);
                    > if (dist>radius) {
                    > var angle = Math.atan2(curX, curY);
                    > curX = radius*Math.sin(angle);
                    > curY = radius*Math.cos(angle);
                    > }
                    > this._x=curX+cX;
                    > this._y=curY+cY;
                    > updateAfterEvent();
                    > };
                    > };
                    > ball.onRelease = ball.onReleaseOutside=function () {
                    > delete this.onEnterFrame;
                    > };
                    >


                    • 7. Re: mouse and circle
                      Rothrock Level 5
                      I'm at work and won't be able to work on this for quite awhile. But what is the fun of having somebody else do it all for you?

                      It is all there for you. First work on making it work for one eye.

                      Hint#1. The size of myCircle should be fairly small compared to the size of ball.

                      Hint#2. I'm guessing you also want a rotational component? If so look up Math.atan2() in the help files. It is giving the angle between the center of the circle and the pointer. So just a little bit of magic and you will have a value to set for _rotation.

                      Hint#3. Take all the stuff in the onMouseMove and make it a function that can be called for each eye.

                      Good luck. I will check back but don't know when I will have time to work on this.