ActionScript - Controlling the Mouse Cursor
Part 2 - Code

In Part 1: Creating the Cursors, I described how to create a cursor library that can be reused in several projects. On this page, I describe the code that actually displays the cursors.

Getting Started | Package | Calling the code


Getting Started

The Flash help provides a pretty decent example on how to modify the mouse cursor at the bottom of the Mouse class description. This page provides an overview of the technique and the modifications necessary to create a class to simplify implementation.

This code assumes that you already have a Movie Clip that will be used as a cursor.

To simulate a cursor you must

The code to perform these functions is attached to events


Package

I define classes in a package so that they can be easily reused. Because mine is still under construction, this will only describe the basics.

I come from a Delphi programming background, so I am following Delphi syntax and design rules. This means that

These are the events


Calling the code

The current code only handles one cursor icon and one target per instance of TMouseCursors. Any number of targets can be defined using multiple instances of TMouseCursors.

In the following example, target1 and target2 are single frame Movie Clips (so they can have names). cursors is an imported Movie Clip that contains several named cursors, cursors.DoubleVert refers to one of the cursors.


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Languages / ActionScript / Mouse_Cursor_Code.html