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.
Tags: ActionScript, as3, Basics, Beginners, Tutorial








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