Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 Knowledgebase
Replace The Mouse Cursor II (Crosshairs)  

Download .fla

How to create the crosshair effect.


Actionscript

onMouseMove = function (){
Mouse.hide();
circle_mc._x = _root._xmouse;
circle_mc._y = _root._ymouse;

vbar_mc._x = _root._xmouse;
hbar_mc._y = _root._ymouse;

updateAfterEvent();
}


How The Actionscript Works

onMouseMove = fucntion() {

 

This event handler calls the function every time the mouse moves.


my_mc._x = _root._xmouse;
my_mc._y = _root._ymouse;

 

The function is defined so that the x and y co-ordinates of the movie clip are made equal to the x and y co-ordinates of the cursor on the stage.


updateAfterEvent();
}

 

this "updateafterevent" built in function, tells our function to refresh the displayed position each time an event is registered in this case our event is movement of the mouse. This is independent of the frame rate.


Note: updateafterevent() function only works inside an onClipEvent() event handler. Also note the updateafterevent () only functions effectively with certain onclipevents (mouseMove, mouseUp, mouseDown, KeyDown and KeyUp) mouse classes.


© 2008 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us