# Cursor effect in AS3

**URL:** <https://forum.kirupa.com/t/cursor-effect-in-as3/276342>\
**Category:** Uncategorized\
**Created:** [November 26, 2008, 12:19am UTC](https://forum.kirupa.com/t/cursor-effect-in-as3/276342 "2008-11-26T00:19:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![juskin](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@juskin](https://forum.kirupa.com/u/juskin)\
**Post date:** [November 26, 2008, 12:19am UTC](https://forum.kirupa.com/t/cursor-effect-in-as3/276342/1 "2008-11-26T00:19:18Z")

</div>

so Im working on a game and ive been asked to do it in as3 which has been painful… so an overview of what im doing, im having a clip replace the mouse, and im having 5 objects listen for a click to swap the clips, one is a hammer up, and one is a hammer down. here is the code. now one bug or problem is if the user rolls out before the “UP” is registered, it leaves the down hammer, so I figured I would try a roll out function that says if the mouse rolls out, load the original hammer and remove the downstate hammer… here is the code…

var mClip:greyMC = new greyMC;  
var upHammer:AngledHammer = new AngledHammer;  
var downHammer:DownHammer = new DownHammer;  
addChild(mClip);  
addChild(upHammer);

stage.addEventListener(MouseEvent.MOUSE\_MOVE, dragCursor)  
function dragCursor(event:MouseEvent):void {  
upHammer.x = this.mouseX;  
upHammer.y = this.mouseY;  
upHammer.mouseChildren = false;  
upHammer.mouseEnabled = false;  
Mouse.hide();  
}

mClip.x = 50;  
[//mCLip.y](https://mCLip.y) = 50;

mClip.buttonMode = true;

mClip.addEventListener(MouseEvent.MOUSE\_UP, mouseUpFunction);  
function mouseUpFunction(event:MouseEvent) {  
trace(“mouse up”);  
addChild(upHammer);  
removeChild(downHammer);  
}

mClip.addEventListener(MouseEvent.MOUSE\_DOWN, mouseDownFunction);  
function mouseDownFunction(event:MouseEvent) {  
trace(“mouse down”)  
addChild(downHammer);  
removeChild(upHammer);  
}

mClip.addEventListener(MouseEvent.MOUSE\_OUT, mouseOutFunction);  
function mouseOutFunction(event:MouseEvent) {  
trace(“mouse out”)  
addChild(upHammer);  
removeChild(downHammer);  
l
