Going through some old stuff again and stumbled on this… if you guys can use it for whatever… I’m having a very bored if you can’t tell…
This class is extremely simple to use, you just create a new instance of it passing into the constructor either the instance name of the movieclip that you would like to follow the mouse, or the identifier name that you gave the symbol in the library… then you call activate() to make it your cursor and deactivate() to make it not your cursor…
Saved as, CustomCursor.as
/*
* @author Michael Avila
* @version 1.0
*/
class CustomCursor
{
// our cursor movieclip
private var cursor : MovieClip;
private var event_cursor : MovieClip;
/* Our CustomCursor Constructor
*
* @param Either the instance name of the movieclip that you are using as a custom cursor or
* the identifier name that you gave it in the Library.
*
* @usage <pre>var cursor = new CustomCursor(my_cursor);// movieclip
* // or
* var cursor = new CustomCursor("my_cursor");// from library
* </pre>
*/
public function CustomCursor( cursor : Object )
{
switch (typeof cursor)
{
case "string":
this.cursor = _root.attachMovie(cursor.toString(), cursor.toString(), _root.getNextHighestDepth());
break;
case "movieclip":
this.cursor = MovieClip(cursor);
break;
default:
trace("You must supply either an identifier name or an instance name");
break;
}
event_cursor = _root.createEmptyMovieClip("alsdkfj", 13000);
event_cursor.onMouseMove = function() { updateAfterEvent() };
}
/* Activates our cursor, activation involves hiding the Mouse and telling our CustomCursor to follow the mouse position. */
public function activate()
{
Mouse.hide();
Mouse.addListener(this);
}
/* Deactivates our cursor, deactivation involves showing the mouse and telling our custom cursor to stop following the mouse positions */
public function deactivate()
{
Mouse.show();
Mouse.removeListener(this);
}
// gets called when the mouse moves
public function onMouseMove():Void
{
cursor._x = _root._xmouse;
cursor._y = _root._ymouse;
updateAfterEvent();
}
}
Code as it would appear in the .fla
var cursor = new CustomCursor(my_cursor);// uses mc that is already on stage
// or
var cursor1 = new CustomCursor("my_cursor");// pulls from library
cursor.activate();
Take Care guys.
_michael