5 Replies Latest reply: Jan 16, 2013 2:37 AM by moccamaximum RSS

    how to bring mouse point to a particular position

    rahimhaji Community Member

      Dear Friends,

       

      i need to bring my mouse cursor point to a particualr place in my stage after click on a particular button. is there any way to bring my mouse cursor to a particular point?

       

      for example: after click on my button:

       

      mouseX = 100;

       

      it tells as mosueX is read only..:)

       

      pls provide me some alternate...

       

      Regards,

      Syed Abdul Rahim

        • 1. Re: how to bring mouse point to a particular position
          moccamaximum Community Member

          You could use a Virtual Mouse or a Custom Cursor that would help you to fake such a behaviour.

          • 2. Re: how to bring mouse point to a particular position
            rahimhaji Community Member

            Dear Mr.Mocca,

             

            Greetings! thks for the answer. I did my own custom (hand) mousepointer.. when the user clicks on a particular button, hand will be vanished and mouse will be shown. When our computer mouse shown to the user, it starts from the place where we clicked. so i want to bring my mouse pointer back in different place like bottom of the screen. My custom mousepointer will come in particular time only.. after clicks on that area it will go...

             

            pls any help my friends..?

             

            Thanks and Regards,

            Syed Abdul Rahim

            • 3. Re: how to bring mouse point to a particular position
              moccamaximum Community Member

              It must be clear that actually controlling the users mouse is not possible.

              That is why I wrote "fake".

              I´give you an example:

               

              Say I have two buttons A and B that I want to have the user click consecutively, that means, if he clicks A it is mandatory for him to click B, but I obviously can`t force him to click it.

               

              When he clicks A, I call

              Mouse.hide() and excange the systems cursor with a MovieClip that looks identical.

              Then I position this clone at the position the original cursor (that is now hidden) sits.

              Then I Tween this clone to the Position where Button B sits and "fake" my clicked animation.

               

              Now in the meantime between this two clicks the User could have moved his mouse anywhere on Stage or even out of your applications focus to the browser menu.

               

              So when I have fake-clicked my Button B I tween my clone whereever the users mouse sits (or to the point where he left the stage) and then I re-exchange the Clone with the original by setting the clone`s visible property to false and calling

               

              Mouse.show()

               

              PS: I just saw that you have another related thread on this forum:

              How to restrict the custom mouse cursor area

              And that you started to mixup the two subjects. That`s actually not very helpful.

              It was a good decision to seperate the problems, the more defined/concentrated your problem, the greater is the chance you will get a solution quickly.

              Just my 2 cents ;-)

              • 4. Re: how to bring mouse point to a particular position
                rahimhaji Community Member

                Thks Mr.Mocca,

                 

                Actually its happending wt u mentioned. i cannot use virutal, thats y i faked my cursor point with hand one. but if the userdid not move the mouse after click, next time when i exhange my cursor, it coms in the same place... this the problem..

                 

                actually my previous thread Mr.kglad answered, so i have send him the reply, along with this...:)

                • 5. Re: how to bring mouse point to a particular position
                  moccamaximum Community Member

                  It`s critical that you understand that even if you call Mouse.hide() its only invisible, not actually removed from stage.

                  So if you include this

                   

                  var currentMouseX:Number;

                  var currentMouseY:Number;

                   

                  stage.addEventListener(MouseEvent.MOUSE_MOVE,getMousePosition);

                  function getMousePosition(e:MouseEvent):void
                  {
                  currentMouseX = e.target.mouseX;
                  currentMousey = e.target.mouseY;
                  }

                   

                  it will always store the last known position of your MouseCursor.

                  This information can be used to tween your custom Cursor to this position before you show the Mouse.

                  That way you create the illusion that the user never lost control of the mouse.

                   

                  Use a tweenengine like TweenLite to achieve that feature.

                   

                  TweenLite.to(customCursor,1,{x:currentMouseX, y:currentMouseY, onComplete:showMouse});

                   

                  function showMouse():void{

                  Mouse.show();

                  customCursor.visible = false;

                  }