Custom cursor on roll over
Hi guys,
I'm trying to get my cursor to change to a custom MovieClip when a certain area is rolled over. My code works but as soon as the rollover is fired the rollout is also fired which creates a loop back and forth the two listeners so the cursor looks like its flickering. I think it may be something to do with the startDrag/stopDrag i have on the custom cursor as i don't get this effect if i remove them. This seems like it should be really straight forward to do but i've tried a few different approaches and keep getting the same effect. What am i missing?
Cheers!
Matt
Code as follows:
var customCursor_mc:CustomCursor = new CustomCursor();
activeArea_mc.addEventListener(MouseEvent.ROLL_OVER, handleEvents);
activeArea_mc.addEventListener(MouseEvent.ROLL_OUT, handleEvents);
activeArea_mc.addEventListener(MouseEvent.CLICK, handleEvents);
function handleEvents(e:MouseEvent):void
{
switch(e.type)
{
case "click":
trace("clicked");
break;
case "rollOver":
trace("over");
Mouse.hide();
customCursor_mc.startDrag(true);
addChild(customCursor_mc);
break;
case "rollOut":
trace("out");
Mouse.show();
customCursor_mc.stopDrag();
removeChild(customCursor_mc);
break;
}
}