12 Replies Latest reply on Jul 18, 2007 7:17 AM by LauriMueller

    keep mouse out of an area

    LauriMueller
      I create graphics for events (shows, meetings, etc.). I have a flash game where one area of the screen is the actual game board projected onscreen and the rest of the screen is for the person managing the game and not seen by the audience. I want to prevent the operator's mouse from entering the game board space (and being seen by the audience) while they are managing the game.

      Is there a way to define a rectangular area where the mouse cannot enter?
        • 1. Re: keep mouse out of an area
          kglad Adobe Community Professional & MVP
          no. but you can use the mouse methods to make it appear that the user's mouse is not entering any give region.
          • 2. Re: keep mouse out of an area
            LauriMueller Level 1
            thanks. It's unfortunate that I would have to deal with a disappearing mouse but it seems that's the only straightforward method. But maybe there's a calculation I could do within an IF statement so that if the mouse is within certain coordinates it would recalculate the position so that it's out of that area. I'll have to play around with it.
            • 3. Re: keep mouse out of an area
              cayennecode Level 1
              sure, you could do a hit test, or you listen for mouseOver events and use those to hide the cursor.
              • 4. Re: keep mouse out of an area
                LauriMueller Level 1
                I know it's hard for you to understand what I'm talking about and the unique situation I'm working under so I made a general screenshot:

                http://www.muellermultimedia.com/images/game.jpg

                Maybe the hit test will work and I can kick the mouse out of the live area so it rides just outside the live area until I clear it. I don't want to hide the cursor because it's not a good idea to lose sight of my cursor while I'm trying to run the game. It all happens too fast and under stress.

                thanks!
                • 5. Re: keep mouse out of an area
                  kglad Adobe Community Professional & MVP
                  well, you'll have to hide the cursor but the user doesn't need to know that because you will use a movieclip of the cursor that simply stops moving when the out of bounds region is reached.
                  • 6. Re: keep mouse out of an area
                    LauriMueller Level 1
                    quote:

                    Originally posted by: kglad
                    well, you'll have to hide the cursor but the user doesn't need to know that because you will use a movieclip of the cursor that simply stops moving when the out of bounds region is reached.


                    I have no idea what you mean. That's ok, you don't understand what I need. I'll figure it out myself. thanks for trying
                    • 7. Re: keep mouse out of an area
                      kglad Adobe Community Professional & MVP
                      you're welcome.
                      • 8. Re: keep mouse out of an area
                        cayennecode Level 1
                        you dont want the cursor hidden while over the live audience area?
                        and showing while not over it?

                        You cannot make a cursor be other than where it is but as kglad suggested you can fake it such that no one would know the difference.

                        Good luck!
                        • 9. keep mouse out of an area
                          LauriMueller Level 1
                          quote:

                          Originally posted by: cayennecode
                          you dont want the cursor hidden while over the live audience area?
                          and showing while not over it?

                          You cannot make a cursor be other than where it is but as kglad suggested you can fake it such that no one would know the difference.

                          Good luck!


                          It's a less desirable option but I won't know for sure until I try it. Imagine you are trying to quickly enter data and need to move your mouse around the screen to reach various input areas. Can you imagine how tough it would be to quickly and accurately mouse when the cursor occasionally disappears and you don't know where it is for a second? On the other hand, being restricted to the "L"-shaped area might be worse. I'll work on this myself and post if I find the answer I want.
                          • 10. Re: keep mouse out of an area
                            LauriMueller Level 1
                            UPDATE:

                            I was able to do a cursor replacement and adjust its position after a hit test but it wasn't a good solution because the cursor image flashed off and on as the position was reevaluated. This code to hide the cursor as it passes over the "no cursor" zone works:

                            • 11. Re: keep mouse out of an area
                              kglad Adobe Community Professional & MVP
                              again, there's no need for the user to see any flash or have any idea that they're being fooled into thinking their cursor is limited to your area.

                              the easiest way to do that is to hide the user's mouse at the start of your application and use a custom cursor (that looks just like the regular cursor, if you want). update the cursor's position your onMouseMove method unless there's a failed hitTest.
                              • 12. Re: keep mouse out of an area
                                LauriMueller Level 1
                                quote:

                                Originally posted by: kglad
                                again, there's no need for the user to see any flash or have any idea that they're being fooled into thinking their cursor is limited to your area.

                                the easiest way to do that is to hide the user's mouse at the start of your application and use a custom cursor (that looks just like the regular cursor, if you want). update the cursor's position your onMouseMove method unless there's a failed hitTest.


                                I said I tried that. it didn't meet my needs because it would jump back and forth rapidly between the hit area and the adjusted area while it was evaluating the hit test and shows. The hide solution is adequate for my needs. thanks anyway.