Trying to figure out how to hide and show the mouse in as3? It’s simple. Here’s the deal.
Imports Required:
imports allow us to use other classes within our application. Simply add it inside your package if within a class.
- flash.ui.Mouse;
Now when you want your Mouse to disappear just call Mouse.hide();
To reappear the mouse simply call Mouse.show();
Example:
Make the mouse disappear and reappear with each click.
Document Class:
package { import flash.ui.Mouse; import flash.display.MovieClip; import flash.events.*; public class MouseToggle extends MovieClip { private var mouseToggle:Boolean = true; public function MouseToggle() { stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 0, true); } function mouseDownHandler(e:MouseEvent) { if (mouseToggle) Mouse.hide(); else Mouse.show(); mouseToggle = !mouseToggle; } } }
I know that was quick and easy… but hey! that’s a Quick Tip.
Similar Posts:
- An Even Better AS3 OOP Flash Custom Cursor
- Creating an AS3 Object Oriented Custom Cursor
- Making a Complete Flash Game: Menus, UI, Screens, or Windows
- AS3 Character Movement: Follow the Mouse Controls
- Changing Colors Dynamically with ColorTransform in AS3









Dear Sir
I have tried to work out your code but its not working at my end I want your help is it possible to discuss with you regarding this example.
help me to solve this issue.
waiting for your reply
Anup
Are you using it as the document class? Please sign up for a forum account and post your issue there and I or someone will do our best to assist you.
mmm…
Could you explain the ‘imports’ and why are you extending to ‘MovieClip’?
As i’m new in both POO and AS3 i’m confused.
Here is what i understand:
importing ui.Mouse for Mouse.show and Mouse.hide methods
importing events.* for MouseEvent.MOUSE_EVENT event
But how about importing and extending ‘MovieClip’ (im really confused at this point, are the same ‘MovieClip’s?, what they are used to?)
There are other articles on this website that explain that. Search for them.
http://asgamer.com/2009/flash-game-design-basics-adding-library-objects-to-stage-with-as3
This doesn’t seem to be working for me in Firefox 5. As a matter of fact, the button mouse hand icon doesn’t even appear. It works in Safari. Any tips?
Hi,
Somehow the example doesn’t work on my Mac. If I click, the cursor disappears, but it doesn’t come back. If I try it on another Mac, it does work. Any ideas on this?
Thanks,
AP