2 Replies Latest reply on May 16, 2006 5:07 PM by wally_errrr

    Mouse Control

      Hi there,

      I have a flash game that is a maze and the user moves through the maze using the mouse. Because I cant directly control the mouse position. I am moving a cursor relative to what the mouse is doing and that works fine. The thing is if the hardware mouse hits the edge of the SWF it doesnt register the mouse move anymore. Basically i want to be moving my movieclip cursor whenever the mouse moves. Beacuse i am not guaranteed of the hardware mouse position being in the middle of where my player starts in the maze.

      I hope this makes sense. I guess i want to do something similar to what they do with first person shooters where the mouse is hidden (done that) and locked to the center of the screen and just used for movement.

      Thanks in advance,

        • 1. Re: Mouse Control
          TimSymons Level 1
          Here is a line from the Help Docs:

          "A Flash application can only monitor mouse events that occur within its focus. A Flash application cannot detect mouse events in another application."

          So, it sounds like unless you can make the entire screen the Flash app, this won't be possible with just Flash.

          • 2. Re: Mouse Control
            wally_errrr Level 1
            Thanks for that,

            Yeah it still is proving to be a bit of a probelm. It will be running full screen, which is one thing in my favour but the way i control my custom cursor is one of the following options.

            - Have it move relative to the mouse position
            -Detect the direction of the mouse and move my cursor in the right direction

            To make sure that the mouse is in a decent starting position when they control the cursor, there is a button that they need to click to start the maze over the starting position of my custom cursor. The same was what people do with the scary flash maze games that are on the net.

            I wish there was someway of having system level access to the mouse. If you could put some assembler in there or something like that. I am guessing there wouldnt be, anyone have any other ideas? Could you write a plugin or something like that?

            Basically this is the way that my maze works. A background image is loaded that represents the maze itself. A tracking image is loaded into a BitmapData object that is colored in a solid color where the user can travel. So by using the mouse coords, check to see if the position to move to is of the same color, if so, move the custom cursor there. If not then dont move it.

            It works well with my first method of mouse movement if you move slowly, but if there is a big jump in the speed of the mouse. You can jump through walls of the maze etc....which is not great.

            My second form of mouse movement also works, but it doesnt seem as smooth as the first. Mainly because it is moving a linear distance each time, based on mouse direction. So it wont be relative to the mouse cursor either, which could provide some issues if the maze is played for sometime.

            Hope someone has some ideas out ther.

            All the best,