4 Replies Latest reply on Sep 22, 2011 6:41 PM by Adam-C

    _mouse.mouseLoc question

    czigany Level 1

      I need to move the mouse to different locations based on a random value. Sometimes the _mouse.mouseLoc function works; sometimes it doesn't. I know that the function is being called. Are there certain circumstances that are required to do this?

       

      Here's the code I'm using:

       

        RandomNum = Random(4)

        case RandomNum of

          0:set xloc = 100

            set yloc = 40

          1:set xloc = 300

            set yloc = 40

          2:set xloc = 500

            set yloc = 40

          3:set xloc = 700

            set yloc = 40

          4:set xloc = 900

            set yloc = 40

        end case

       

        _mouse.mouseLoc=point(xloc,yloc)

       

       

      This is for a Shockwave movie.

        • 1. Re: _mouse.mouseLoc question
          Wolfgang Herold Level 2

          did you try "updatestage" ?

          Maybe that helps.

           

          Wolfgang

          • 2. Re: _mouse.mouseLoc question
            czigany Level 1

            I did try Updatestage actually. I'm grasping at straws here.

             

            By the way, I'm using the exact same code later in my movie and it works great there. I'm still trying to figure out what's different between the two instances.

            • 3. Re: _mouse.mouseLoc question
              Adam-C Level 2

              Given that this is intermittent, you could run a repeat loop that keeps attempting to set _mouse.mouseLoc until the mouse responds. You'd need to put a counter in there too so you didn't risk having an infinite loop, but something like this maybe:

               

              --all your existing code to determine the random location of the pointer, then...

               

              set repCounter = 0

              set repLimit = 100

              repeat while _mouse.mouseLoc <> point(xLoc, yLoc)

                   _mouse.mouseLoc = point(xLoc, yLoc)

                   repCounter = repCounter +1

                   _movie.updateStage()

                   if repCounter > repLimit then

                        exit repeat

                   end if

              end repeat

               

              Gotta say, I didn't realise you could set the mouseLoc in this way - I thought it was a read-only property.

               

              BTW - the Buddy Api Xtra (which is cross-platform and Director 11+ compatible) has a placeCursor() method - this may be your best option. It's an excellent Xtra too - loads of useful functions in there and worth every penny. Check it out at http://www.mods.com.au/budapi/

              • 4. Re: _mouse.mouseLoc question
                Adam-C Level 2

                Are there certain circumstances that are required to do this?

                Could it be anything to do with the mouse being moved/used by the user when the program first runs (and you are getting this problem), whereas when you use the technique later in the program the user wouldn't be using the mouse? I'm just thinking that the user's attempts to move the mouse could be overriding your attempts to set the mouse.