/** * Custom Cursor Class v0.1: AS2 custom movieclip cursor - http://jaycsantos.com * Copyright (C) 2008 Jayc Santos * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . * * You can completely modify the following below but please leave this text above to keep credit. * **/ class MCCursor extends MovieClip { //singleton static var cur:MCCursor; var frame:Object; var onMouseMove2:Function; /** * Constructor. You can have any depth set on the movieclip * upon dynamically loading it on stage or even if it is on * the timeline during design time, the constructor will * swap depths so it keeps the cursor above all display objects. * */ function MCCursor(){ Mouse.hide(); gotoAndStop(1); if ( cur ) { cur.removeMovieClip(); } // singleton class cur = this; // swap to a very high but still safe depth swapDepths( 1048031 ); } /** * this automatically follows the mouse' position upon moving * the moving it * * if you want to have your own onMouseMove function you can * use onMouseMove2 instead to not overwrite this method * * MCCursor.cur.onMouseMove2 = function(){ * //do what you want * } * **/ function onMouseMove(){ _x += _xmouse; _y += _ymouse; onMouseMove2(); } /** * this hides the mouse again when the swf looses focus * * if you want to have your own onMouseMove function you can * use onMouseMove2 instead to not overwrite this method * * MCCursor.cur.onMouseMove2 = function(){ * //do what you want * } * **/ function onMouseDown(){ Mouse.hide(); /** * it doesn't seem to reflect the mouse' position when focus was just regained, * try right clicking then clicking on stage, you'll see what I mean. * I'll have to find a work around with this, or it simply isn't supporeted in AS2 * */ //this.onMouseMove(); } /** * f parameter can be a number or a string (frame label), * it will be stored on frame variable regardless * if it is a valid frame from the movieclip or not * */ function gotoAndStop( f:Object ) { super.gotoAndStop( f ); frame = f; } /** * for convieniency, use the this static function to set * the frame of the cursor and can be accessed anywhere * * how to use: * MCCursor.gotoFrame( f ); * * where f is a numeric value or string of the made frame label * * */ static function gotoFrame( f:Object ) { if ( !cur ) return; cur.gotoAndStop( f ); } /** * set getFrameNumber parameter to true to force returning the * actual numberic value of the current frame of the movieclip * */ static function getFrame( getFrameNumber:Boolean ):Object { if ( !cur ) return null; if ( getFrameNumber ) return cur._currentframe; else return cur.frame; } }