ActionScript3:Custom Mouse Pointers
|Flash10 (CS4) <|
|Table of contents|
Use a custom graphic as a mouse pointer using ActionScript 3
By the end of this exercise you should be able to:
Create the Graphic
Using graphic software such as Adobe Photoshop, Corel Draw or PaintShop Pro, create a graphic to be used in place of the standard mouse pointer. Photoshop has a great range of shapes, including one resembling a barrel crosshair sight. Create with a transparent background, save as a png and import to the stage of your Actionscript 3 movie.
Convert to a movieClip, tick the Export For Actionscript checkbox and give it a class name of
Cursor. Give the movieClip an instance name of
crosshair and then delete from the stage. The movieClip will still reside in the Library and will be called via ActionScript.
Inserting the ActionScript
Open the Actions panel on frame One of your actions layer and insert the following code:
To change the mouse pointer back to normal as it passes over a button for example, use an eventListener on the button for a
MOUSE_OVER Event and use the
Mouse.Show() function. Use
MOUSE_OUT as the mouse leaves the button.