Copy link to clipboard
Copied
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;
}
}
Hm, that sounds like the cursor itself is causing the problem. Set it to mouseEnabled = false and mouseChildren = false
Copy link to clipboard
Copied
Add a transparent Shape (i.e. just draw with the Rectangle or Rectangle primitive tool) over everything inside the thing you're rolling over. ROLL_OUT is being triggered because it's rolling over an internal object.
Copy link to clipboard
Copied
Hi Amy,
Thanks for the reply, i've just tried your solution but it doesn't seem to make any difference. The clip being rolled over is a movieClip with a rectangle primitive inside, this defines a 'hit' area. if i remove the startdrag the rollOut/Over events fire as expected. Sorry perhaps i've misunderstood what you meant?
Matt
Copy link to clipboard
Copied
Hm, that sounds like the cursor itself is causing the problem. Set it to mouseEnabled = false and mouseChildren = false
Copy link to clipboard
Copied
Ah ha! Thanks Amy that seems to of solved it. Seems strange that was causing the issue though as the cursor clip is just an mc without any mouse event listeners on it at all?! Probably just a strange issue with Flash maybe!
Many Thanks
Matt
Find more inspiration, events, and resources on the new Adobe Community
Explore Now