Tutorial: How to replace and hide the cursor in Flash with ActionScript 3

I will show you how to hide the mouse cursor and how to replace it by another image.

It’s really simple but you need one at least one MovieClip.

[swf:/wp-content/uploads/2013/03/Hide_mouse_cursor_and_custom_cursor.swf 550 400]

You also can download the source file: Hide_mouse_cursor_and_custom_cursor.fla.

  • Create a new ActionScript 3 file.
  • Insert > New Symbol > MovieClip > name: CustomCursor > Ok.
  • Customize your cursor and set the origin on the top of the cursor.
  • Back to your main stage.
  • Add a CustomCursor MovieClip in the stage.
  • Set the instance name in the MovieClip property: Click on the CustomCursor instance > Properties pannel > Set instance name: cursor
  • Open the Actions pannel and start to code.
// https://www.benoitfreslon.com

// Hide the mouse cursor
Mouse.hide();

// Use the custom cursor

// cursor is the instance name in the stage
// Tip: Add the cursor always on top.
stage.addChild(cursor);

// Drag the cursor to the mouse coordinates
cursor.startDrag(true);

// Show the mouse cursor
//Mouse.show();

That’s all :).